feat: add support for xAI

This commit is contained in:
Ryo Shen
2024-11-07 13:34:08 +08:00
parent 7e51b04221
commit 4b32c6142b
10 changed files with 29 additions and 2 deletions

View File

@@ -11,9 +11,10 @@ import (
"github.com/songquanpeng/one-api/relay/adaptor/mistral"
"github.com/songquanpeng/one-api/relay/adaptor/moonshot"
"github.com/songquanpeng/one-api/relay/adaptor/novita"
"github.com/songquanpeng/one-api/relay/adaptor/siliconflow"
"github.com/songquanpeng/one-api/relay/adaptor/stepfun"
"github.com/songquanpeng/one-api/relay/adaptor/togetherai"
"github.com/songquanpeng/one-api/relay/adaptor/siliconflow"
"github.com/songquanpeng/one-api/relay/adaptor/xai"
"github.com/songquanpeng/one-api/relay/channeltype"
)
@@ -32,6 +33,7 @@ var CompatibleChannels = []int{
channeltype.TogetherAI,
channeltype.Novita,
channeltype.SiliconFlow,
channeltype.XAI,
}
func GetCompatibleChannelMeta(channelType int) (string, []string) {
@@ -64,6 +66,8 @@ func GetCompatibleChannelMeta(channelType int) (string, []string) {
return "novita", novita.ModelList
case channeltype.SiliconFlow:
return "siliconflow", siliconflow.ModelList
case channeltype.XAI:
return "xai", xai.ModelList
default:
return "openai", ModelList
}

View File

@@ -0,0 +1,5 @@
package xai
var ModelList = []string{
"grok-beta",
}

View File

@@ -208,6 +208,8 @@ var ModelRatio = map[string]float64{
"deepl-zh": 25.0 / 1000 * USD,
"deepl-en": 25.0 / 1000 * USD,
"deepl-ja": 25.0 / 1000 * USD,
// https://console.x.ai/
"grok-beta": 5.0 / 1000 * USD,
}
var CompletionRatio = map[string]float64{
@@ -372,6 +374,8 @@ func GetCompletionRatio(name string, channelType int) float64 {
return 3
case "command-r-plus":
return 5
case "grok-beta":
return 3
}
return 1
}

View File

@@ -46,5 +46,6 @@ const (
VertextAI
Proxy
SiliconFlow
XAI
Dummy
)

View File

@@ -45,7 +45,8 @@ var ChannelBaseURLs = []string{
"https://api.novita.ai/v3/openai", // 41
"", // 42
"", // 43
"https://api.siliconflow.cn", // 44
"https://api.siliconflow.cn", // 44
"https://api.x.ai", // 45
}
func init() {