From d33b802dac7e4732bd705077485981a1724f056f Mon Sep 17 00:00:00 2001 From: Akarin Date: Thu, 16 May 2024 14:05:44 +0800 Subject: [PATCH] Squashed commit of the following: commit 5a6a0df45dee3dfbf2f65591a79fe5f2b74a49e6 Author: Akarin Date: Thu May 16 14:05:28 2024 +0800 Revert "Update docker-image-amd64.yml" This reverts commit 581343a78783bbd779e65b476e125af0e2b64ce5. commit a0aec1bd030da2c6b25d9541199d598f16813a60 Merge: 5b46c7d 58abb38 Author: Jiayun Shen Date: Thu May 16 06:46:51 2024 +0800 Merge branch 'main' of https://github.com/jimmyshjj/new-api commit 58abb3864a89294d82f812cda9fe49ccf7e2dd91 Merge: 7d2c026 93858c3 Author: Akarin Date: Thu May 16 06:46:00 2024 +0800 Merge branch 'Calcium-Ion:main' into main commit 5b46c7dd8e6132d2be3b59c7b2ed6a4b84b93cef Author: Jiayun Shen Date: Thu May 16 06:45:00 2024 +0800 Update constants.go Remove replaced Baidu models commit 7d2c02679cd90b8b53f4145f83969b980a8c2095 Author: Akarin Date: Wed May 15 23:40:50 2024 +0800 Update adaptor.go - Normalize model name to lowercase Baidu's official model names may include mixed case letters, but their model APIs are case-sensitive and accept only lowercase. To ensure compatibility, the default behavior has been updated to convert model names to lowercase before constructing API requests. commit 6bc168a39d9a6194d66f2f32b175e56de9295b2e Merge: bb9fecd 910e76a Author: Jiayun Shen Date: Wed May 15 21:51:52 2024 +0800 Merge branch 'main' of https://github.com/jimmyshjj/new-api commit 910e76ac94d7f5dca6254abb4d0669cbb762e724 Merge: 581343a ff044de Author: Akarin Date: Wed May 15 21:51:13 2024 +0800 Merge branch 'Calcium-Ion:main' into main commit bb9fecd5bf2bd9f1859a4017e7e68f80bdb6685a Author: Jiayun Shen Date: Wed May 15 21:50:08 2024 +0800 update Baidu and 360 models Add Baidu and 360 new models. Add Baidu completion ratio commit 581343a78783bbd779e65b476e125af0e2b64ce5 Author: Akarin Date: Wed May 15 19:41:34 2024 +0800 Update docker-image-amd64.yml commit de17e2d95eec80f1eeae66e82dec4e9601cdee43 Merge: 046f653 a3b3e6c Author: Akarin Date: Wed May 15 19:22:09 2024 +0800 Merge branch 'Calcium-Ion:main' into main commit 046f6537913ae8ad8ecf21019b64c0379331b3fd Merge: 4164d51 7b58305 Author: Akarin Date: Wed May 15 15:32:38 2024 +0800 Merge branch 'Calcium-Ion:main' into main commit 4164d51207808283a18ca2728241fd5cddc4855f Merge: ef35b07 c222bc8 Author: Akarin Date: Wed May 15 11:19:13 2024 +0800 Merge branch 'Calcium-Ion:main' into main commit ef35b072824b5095ecd2d1ed7ca9fa11673da2c4 Author: Jiayun Shen Date: Tue May 14 19:17:32 2024 +0800 Update adaptor.go Update frequently used model names from Baidu official docs and support custom models --- common/model-ratio.go | 26 +++++++++++++++++++++++--- relay/channel/ai360/constants.go | 3 +++ relay/channel/baidu/adaptor.go | 17 +++++++++++++++++ relay/channel/baidu/constants.go | 18 +++++++++++++----- 4 files changed, 56 insertions(+), 8 deletions(-) diff --git a/common/model-ratio.go b/common/model-ratio.go index 8b66f49..b84a0a5 100644 --- a/common/model-ratio.go +++ b/common/model-ratio.go @@ -69,9 +69,17 @@ var DefaultModelRatio = map[string]float64{ "claude-3-haiku-20240307": 0.125, // $0.25 / 1M tokens "claude-3-sonnet-20240229": 1.5, // $3 / 1M tokens "claude-3-opus-20240229": 7.5, // $15 / 1M tokens - "ERNIE-Bot": 0.8572, // ¥0.012 / 1k tokens - "ERNIE-Bot-turbo": 0.5715, // ¥0.008 / 1k tokens - "ERNIE-Bot-4": 8.572, // ¥0.12 / 1k tokens + "ERNIE-Bot": 0.8572, // ¥0.012 / 1k tokens //renamed to ERNIE-3.5-8K + "ERNIE-Bot-turbo": 0.5715, // ¥0.008 / 1k tokens //renamed to ERNIE-Lite-8K + "ERNIE-Bot-4": 8.572, // ¥0.12 / 1k tokens //renamed to ERNIE-4.0-8K + "ERNIE-4.0-8K": 8.572, // ¥0.12 / 1k tokens + "ERNIE-3.5-8K": 0.8572, // ¥0.012 / 1k tokens + "ERNIE-Speed-8K": 0.2858, // ¥0.004 / 1k tokens + "ERNIE-Speed-128K": 0.2858, // ¥0.004 / 1k tokens + "ERNIE-Lite-8K": 0.2143, // ¥0.003 / 1k tokens + "ERNIE-Tiny-8K": 0.0715, // ¥0.001 / 1k tokens + "ERNIE-Character-8K": 0.2858, // ¥0.004 / 1k tokens + "ERNIE-Functions-8K": 0.2858, // ¥0.004 / 1k tokens "Embedding-V1": 0.1429, // ¥0.002 / 1k tokens "PaLM-2": 1, "gemini-pro": 1, // $0.00025 / 1k characters -> $0.001 / 1k tokens @@ -98,6 +106,9 @@ var DefaultModelRatio = map[string]float64{ "SparkDesk-v3.1": 1.2858, // ¥0.018 / 1k tokens "SparkDesk-v3.5": 1.2858, // ¥0.018 / 1k tokens "360GPT_S2_V9": 0.8572, // ¥0.012 / 1k tokens + "360gpt-turbo": 0.0858, // ¥0.0012 / 1k tokens + "360gpt-turbo-responsibility-8k": 0.8572, // ¥0.012 / 1k tokens + "360gpt-pro": 0.8572, // ¥0.012 / 1k tokens "embedding-bert-512-v1": 0.0715, // ¥0.001 / 1k tokens "embedding_s1_v1": 0.0715, // ¥0.001 / 1k tokens "semantic_similarity_s1_v1": 0.0715, // ¥0.001 / 1k tokens @@ -289,6 +300,15 @@ func GetCompletionRatio(name string) float64 { if strings.HasPrefix(name, "deepseek") { return 2 } + if strings.HasPrefix(name, "ERNIE-Speed-") { + return 2 + } else if strings.HasPrefix(name, "ERNIE-Lite-") { + return 2 + } else if strings.HasPrefix(name, "ERNIE-Character") { + return 2 + } else if strings.HasPrefix(name, "ERNIE-Functions") { + return 2 + } switch name { case "llama2-70b-4096": return 0.8 / 0.64 diff --git a/relay/channel/ai360/constants.go b/relay/channel/ai360/constants.go index 82698fa..824231d 100644 --- a/relay/channel/ai360/constants.go +++ b/relay/channel/ai360/constants.go @@ -1,6 +1,9 @@ package ai360 var ModelList = []string{ + "360gpt-turbo", + "360gpt-turbo-responsibility-8k", + "360gpt-pro", "360GPT_S2_V9", "embedding-bert-512-v1", "embedding_s1_v1", diff --git a/relay/channel/baidu/adaptor.go b/relay/channel/baidu/adaptor.go index d2571dc..44c5e3f 100644 --- a/relay/channel/baidu/adaptor.go +++ b/relay/channel/baidu/adaptor.go @@ -9,6 +9,7 @@ import ( "one-api/relay/channel" relaycommon "one-api/relay/common" "one-api/relay/constant" + "strings" ) type Adaptor struct { @@ -33,8 +34,24 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) { fullRequestURL = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant" case "BLOOMZ-7B": fullRequestURL = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/bloomz_7b1" + case "ERNIE-4.0-8K": + fullRequestURL = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro" + case "ERNIE-3.5-8K": + fullRequestURL = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions" + case "ERNIE-Speed-8K": + fullRequestURL = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/ernie_speed" + case "ERNIE-Character-8K": + fullRequestURL = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/ernie-char-8k" + case "ERNIE-Functions-8K": + fullRequestURL = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/ernie-func-8k" + case "ERNIE-Lite-8K-0922": + fullRequestURL = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant" + case "Yi-34B-Chat": + fullRequestURL = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/yi_34b_chat" case "Embedding-V1": fullRequestURL = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/embeddings/embedding-v1" + default: + fullRequestURL = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/" + strings.ToLower(info.UpstreamModelName) } var accessToken string var err error diff --git a/relay/channel/baidu/constants.go b/relay/channel/baidu/constants.go index a0162bb..3cb96fc 100644 --- a/relay/channel/baidu/constants.go +++ b/relay/channel/baidu/constants.go @@ -1,11 +1,19 @@ package baidu var ModelList = []string{ - "ERNIE-Bot-4", - "ERNIE-Bot-8K", - "ERNIE-Bot", - "ERNIE-Speed", - "ERNIE-Bot-turbo", + "ERNIE-3.5-8K", + "ERNIE-4.0-8K", + "ERNIE-Speed-8K", + "ERNIE-Speed-128K", + "ERNIE-Lite-8K", + "ERNIE-Tiny-8K", + "ERNIE-Character-8K", + "ERNIE-Functions-8K", + //"ERNIE-Bot-4", + //"ERNIE-Bot-8K", + //"ERNIE-Bot", + //"ERNIE-Speed", + //"ERNIE-Bot-turbo", "Embedding-V1", }