🎨 Support Baichuan2

This commit is contained in:
Martial BE
2023-12-29 15:23:05 +08:00
parent c5aa59e297
commit 61c47a3b08
12 changed files with 190 additions and 5 deletions

View File

@@ -189,6 +189,7 @@ const (
ChannelTypeTencent = 23
ChannelTypeAzureSpeech = 24
ChannelTypeGemini = 25
ChannelTypeBaichuan = 26
)
var ChannelBaseURLs = []string{
@@ -218,6 +219,7 @@ var ChannelBaseURLs = []string{
"https://hunyuan.cloud.tencent.com", //23
"", //24
"", //25
"https://api.baichuan-ai.com", //26
}
const (

View File

@@ -101,6 +101,10 @@ var ModelRatio = map[string]float64{
"embedding_s1_v1": 0.0715, // ¥0.001 / 1k tokens
"semantic_similarity_s1_v1": 0.0715, // ¥0.001 / 1k tokens
"hunyuan": 7.143, // ¥0.1 / 1k tokens // https://cloud.tencent.com/document/product/1729/97731#e0e6be58-60c8-469f-bdeb-6c264ce3b4d0
"Baichuan2-Turbo": 0.5715, // ¥0.008 / 1k tokens
"Baichuan2-Turbo-192k": 1.143, // ¥0.016 / 1k tokens
"Baichuan2-53B": 1.4286, // ¥0.02 / 1k tokens
"Baichuan-Text-Embedding": 0.0357, // ¥0.0005 / 1k tokens
}
func ModelRatio2JSONString() string {

View File

@@ -190,13 +190,13 @@ func countImageTokens(url string, detail string) (_ int, err error) {
func CountTokenInput(input any, model string) int {
switch v := input.(type) {
case string:
return CountTokenInput(v, model)
return CountTokenText(v, model)
case []string:
text := ""
for _, s := range v {
text += s
}
return CountTokenInput(text, model)
return CountTokenText(text, model)
}
return 0
}