Browse Source

chore: Update Azure OpenAI API version and embedding model detection

- Enhance channel test to detect more embedding models
- Update Azure OpenAI default API version to 2024-12-01-preview
- Remove redundant default API version setting in channel edit
- Add user cache writing in channel test
[email protected] 10 months ago
parent
commit
1bcf7a3c39

+ 7 - 1
controller/channel-test.go

@@ -48,7 +48,7 @@ func testChannel(channel *model.Channel, testModel string) (err error, openAIErr
 	if strings.Contains(strings.ToLower(testModel), "embedding") ||
 		strings.HasPrefix(testModel, "m3e") || // m3e 系列模型
 		strings.Contains(testModel, "bge-") || // bge 系列模型
-		testModel == "text-embedding-v1" ||
+		strings.Contains(testModel, "embed") ||
 		channel.Type == common.ChannelTypeMokaAI { // 其他 embedding 模型
 		requestPath = "/v1/embeddings" // 修改请求路径
 	}
@@ -84,6 +84,12 @@ func testChannel(channel *model.Channel, testModel string) (err error, openAIErr
 		}
 	}
 
+	cache, err := model.GetUserCache(1)
+	if err != nil {
+		return err, nil
+	}
+	cache.WriteContext(c)
+
 	c.Request.Header.Set("Authorization", "Bearer "+channel.Key)
 	c.Request.Header.Set("Content-Type", "application/json")
 	c.Set("channel", channel.Type)

+ 1 - 2
web/src/i18n/locales/en.json

@@ -1074,10 +1074,9 @@
   "删除所选通道": "Delete selected channels",
   "标签聚合模式": "Enable tag mode",
   "没有账户?": "No account? ",
-  "注意,模型部署名称必须和模型名称保持一致,因为 One API 会把请求体中的 model 参数替换为你的部署名称(模型名称中的点会被剔除)": "Note: The model deployment name must match the model name because One API will replace the model parameter in the request body with your deployment name (dots in the model name will be removed)",
   "请输入 AZURE_OPENAI_ENDPOINT,例如:https://docs-test-001.openai.azure.com": "Please enter AZURE_OPENAI_ENDPOINT, e.g.: https://docs-test-001.openai.azure.com",
   "默认 API 版本": "Default API Version",
-  "请输入默认 API 版本,例如:2023-06-01-preview,该配置可以被实际的请求查询参数所覆盖": "Please enter default API version, e.g.: 2023-06-01-preview. This configuration can be overridden by actual request query parameters",
+  "请输入默认 API 版本,例如:2024-12-01-preview": "Please enter default API version, e.g.: 2024-12-01-preview.",
   "请为渠道命名": "Please name the channel",
   "请选择可以使用该渠道的分组": "Please select groups that can use this channel",
   "请在系统设置页面编辑分组倍率以添加新的分组:": "Please edit Group ratios in system settings to add new groups:",

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

@@ -327,9 +327,6 @@ const EditChannel = (props) => {
         localInputs.base_url.length - 1
       );
     }
-    if (localInputs.type === 3 && localInputs.other === '') {
-      localInputs.other = '2023-06-01-preview';
-    }
     if (localInputs.type === 18 && localInputs.other === '') {
       localInputs.other = 'v2.1';
     }
@@ -494,7 +491,7 @@ const EditChannel = (props) => {
               <Input
                 label={t('默认 API 版本')}
                 name="azure_other"
-                placeholder={t('请输入默认 API 版本,例如:2023-06-01-preview,该配置可以被实际的请求查询参数所覆盖')}
+                placeholder={t('请输入默认 API 版本,例如:2024-12-01-preview')}
                 onChange={(value) => {
                   handleInputChange('other', value);
                 }}