Jelajahi Sumber

feat: support ERNIE-Bot-4 (close #608)

JustSong 2 tahun lalu
induk
melakukan
63fafba112

+ 1 - 0
common/model-ratio.go

@@ -46,6 +46,7 @@ var ModelRatio = map[string]float64{
 	"claude-2":                  5.51,   // $11.02 / 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
 	"Embedding-V1":              0.1429, // ¥0.002 / 1k tokens
 	"PaLM-2":                    1,
 	"chatglm_pro":               0.7143, // ¥0.01 / 1k tokens

+ 9 - 0
controller/model.go

@@ -306,6 +306,15 @@ func init() {
 			Root:       "ERNIE-Bot-turbo",
 			Parent:     nil,
 		},
+		{
+			Id:         "ERNIE-Bot-4",
+			Object:     "model",
+			Created:    1677649963,
+			OwnedBy:    "baidu",
+			Permission: permission,
+			Root:       "ERNIE-Bot-4",
+			Parent:     nil,
+		},
 		{
 			Id:         "Embedding-V1",
 			Object:     "model",

+ 2 - 0
controller/relay-text.go

@@ -152,6 +152,8 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
 			fullRequestURL = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions"
 		case "ERNIE-Bot-turbo":
 			fullRequestURL = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant"
+		case "ERNIE-Bot-4":
+			fullRequestURL = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro"
 		case "BLOOMZ-7B":
 			fullRequestURL = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/bloomz_7b1"
 		case "Embedding-V1":

+ 1 - 1
web/src/pages/Channel/EditChannel.js

@@ -66,7 +66,7 @@ const EditChannel = () => {
           localModels = ['PaLM-2'];
           break;
         case 15:
-          localModels = ['ERNIE-Bot', 'ERNIE-Bot-turbo', 'Embedding-V1'];
+          localModels = ['ERNIE-Bot', 'ERNIE-Bot-turbo', 'ERNIE-Bot-4', 'Embedding-V1'];
           break;
         case 17:
           localModels = ['qwen-turbo', 'qwen-plus', 'text-embedding-v1'];