From 51e17a47fa10ed6a1974468090310e6fcddef8bf Mon Sep 17 00:00:00 2001 From: Archer <545436317@qq.com> Date: Sat, 8 Feb 2025 12:16:46 +0800 Subject: [PATCH] feat: normalization embedding;feat: model top_p param config (#3723) * edit form force close image select * model config * feat: normalization embedding * perf: add share page title force refresh --- .../zh-cn/docs/development/upgrading/4821.md | 9 ++-- .../zh-cn/docs/development/upgrading/490.md | 15 ++++++ packages/global/core/ai/model.d.ts | 1 + .../core/ai/config/provider/ChatGLM.json | 28 +++++++++++ .../core/ai/config/provider/Claude.json | 8 ++++ .../core/ai/config/provider/DeepSeek.json | 9 +++- .../core/ai/config/provider/Doubao.json | 42 +++++++++++++---- .../core/ai/config/provider/Ernie.json | 16 +++++-- .../core/ai/config/provider/Gemini.json | 26 +++++++--- .../service/core/ai/config/provider/Groq.json | 8 +++- .../core/ai/config/provider/Hunyuan.json | 28 ++++++++--- .../core/ai/config/provider/Intern.json | 8 +++- .../core/ai/config/provider/MiniMax.json | 10 ++-- .../core/ai/config/provider/MistralAI.json | 16 +++++-- .../core/ai/config/provider/Moonshot.json | 15 ++++-- .../core/ai/config/provider/OpenAI.json | 35 +++++++++++--- .../service/core/ai/config/provider/Qwen.json | 47 +++++++++++++++---- .../core/ai/config/provider/Siliconflow.json | 14 ++++-- .../core/ai/config/provider/SparkDesk.json | 26 +++++++--- .../core/ai/config/provider/StepFun.json | 46 +++++++++++++----- .../service/core/ai/config/provider/Yi.json | 8 +++- packages/service/core/ai/embedding/index.ts | 21 ++++++++- packages/web/i18n/en/account.json | 2 + packages/web/i18n/zh-CN/account.json | 2 + packages/web/i18n/zh-Hant/account.json | 2 + .../src/components/common/NextHead/index.tsx | 9 +++- .../account/model/ModelConfigTable.tsx | 13 +++++ projects/app/src/pages/_error.tsx | 4 +- .../app/src/pages/api/core/ai/model/test.ts | 8 +++- projects/app/src/pages/chat/share.tsx | 6 ++- 30 files changed, 388 insertions(+), 94 deletions(-) create mode 100644 docSite/content/zh-cn/docs/development/upgrading/490.md diff --git a/docSite/content/zh-cn/docs/development/upgrading/4821.md b/docSite/content/zh-cn/docs/development/upgrading/4821.md index 887543aff..bc647f4f3 100644 --- a/docSite/content/zh-cn/docs/development/upgrading/4821.md +++ b/docSite/content/zh-cn/docs/development/upgrading/4821.md @@ -14,7 +14,8 @@ weight: 804 1. 2. 新增 - LLM 模型支持 top_p, response_format, json_schema 参数。 3. 新增 - Doubao1.5 模型预设。 -4. 优化 - 模型未配置时错误提示。 -5. 修复 - 简易模式,切换到其他非视觉模型时候,会强制关闭图片识别。 -6. 修复 - o1,o3 模型,在测试时候字段映射未生效导致报错。 -7. 修复 - 公众号对话空指针异常。 \ No newline at end of file +4. 新增 - 向量模型支持归一化配置,以便适配未归一化的向量模型,例如 Doubao 的 embedding 模型。 +5. 优化 - 模型未配置时错误提示。 +6. 修复 - 简易模式,切换到其他非视觉模型时候,会强制关闭图片识别。 +7. 修复 - o1,o3 模型,在测试时候字段映射未生效导致报错。 +8. 修复 - 公众号对话空指针异常。 \ No newline at end of file diff --git a/docSite/content/zh-cn/docs/development/upgrading/490.md b/docSite/content/zh-cn/docs/development/upgrading/490.md new file mode 100644 index 000000000..7ded0c9b9 --- /dev/null +++ b/docSite/content/zh-cn/docs/development/upgrading/490.md @@ -0,0 +1,15 @@ +--- +title: 'V4.9.0(进行中)' +description: 'FastGPT V4.9.0 更新说明' +icon: 'upgrade' +draft: false +toc: true +weight: 804 +--- + + + +## 完整更新内容 + +1. 修复 - 简易模式,切换到其他非视觉模型时候,会强制关闭图片识别。 +2. 修复 - o1,o3 模型,在测试时候字段映射未生效导致报错。 \ No newline at end of file diff --git a/packages/global/core/ai/model.d.ts b/packages/global/core/ai/model.d.ts index 6ebacc383..7efd78b86 100644 --- a/packages/global/core/ai/model.d.ts +++ b/packages/global/core/ai/model.d.ts @@ -64,6 +64,7 @@ export type EmbeddingModelItemType = PriceType & maxToken: number; // model max token weight: number; // training weight hidden?: boolean; // Disallow creation + normalization?: boolean; // normalization processing defaultConfig?: Record; // post request config dbConfig?: Record; // Custom parameters for storage queryConfig?: Record; // Custom parameters for query diff --git a/packages/service/core/ai/config/provider/ChatGLM.json b/packages/service/core/ai/config/provider/ChatGLM.json index e687be243..d4ce948bf 100644 --- a/packages/service/core/ai/config/provider/ChatGLM.json +++ b/packages/service/core/ai/config/provider/ChatGLM.json @@ -8,6 +8,12 @@ "maxResponse": 4000, "quoteMaxToken": 120000, "maxTemperature": 0.99, + "showTopP": true, + "responseFormatList": [ + "text", + "json_object" + ], + "showStopSign": true, "vision": false, "toolChoice": true, "functionCall": false, @@ -30,6 +36,12 @@ "maxResponse": 4000, "quoteMaxToken": 120000, "maxTemperature": 0.99, + "showTopP": true, + "responseFormatList": [ + "text", + "json_object" + ], + "showStopSign": true, "vision": false, "toolChoice": true, "functionCall": false, @@ -52,6 +64,12 @@ "maxResponse": 4000, "quoteMaxToken": 900000, "maxTemperature": 0.99, + "showTopP": true, + "responseFormatList": [ + "text", + "json_object" + ], + "showStopSign": true, "vision": false, "toolChoice": false, "functionCall": false, @@ -74,6 +92,12 @@ "maxResponse": 4000, "quoteMaxToken": 120000, "maxTemperature": 0.99, + "showTopP": true, + "responseFormatList": [ + "text", + "json_object" + ], + "showStopSign": true, "vision": false, "toolChoice": true, "functionCall": false, @@ -96,6 +120,8 @@ "maxResponse": 1000, "quoteMaxToken": 6000, "maxTemperature": 0.99, + "showTopP": true, + "showStopSign": true, "vision": true, "toolChoice": false, "functionCall": false, @@ -118,6 +144,8 @@ "maxResponse": 1000, "quoteMaxToken": 6000, "maxTemperature": 0.99, + "showTopP": true, + "showStopSign": true, "vision": true, "toolChoice": false, "functionCall": false, diff --git a/packages/service/core/ai/config/provider/Claude.json b/packages/service/core/ai/config/provider/Claude.json index 0b43edc21..268d49ffd 100644 --- a/packages/service/core/ai/config/provider/Claude.json +++ b/packages/service/core/ai/config/provider/Claude.json @@ -8,6 +8,8 @@ "maxResponse": 8000, "quoteMaxToken": 100000, "maxTemperature": 1, + "showTopP": true, + "showStopSign": true, "vision": false, "toolChoice": true, "functionCall": false, @@ -30,6 +32,8 @@ "maxResponse": 8000, "quoteMaxToken": 100000, "maxTemperature": 1, + "showTopP": true, + "showStopSign": true, "vision": true, "toolChoice": true, "functionCall": false, @@ -52,6 +56,8 @@ "maxResponse": 8000, "quoteMaxToken": 100000, "maxTemperature": 1, + "showTopP": true, + "showStopSign": true, "vision": true, "toolChoice": true, "functionCall": false, @@ -74,6 +80,8 @@ "maxResponse": 4096, "quoteMaxToken": 100000, "maxTemperature": 1, + "showTopP": true, + "showStopSign": true, "vision": true, "toolChoice": true, "functionCall": false, diff --git a/packages/service/core/ai/config/provider/DeepSeek.json b/packages/service/core/ai/config/provider/DeepSeek.json index 5838de644..df9369e38 100644 --- a/packages/service/core/ai/config/provider/DeepSeek.json +++ b/packages/service/core/ai/config/provider/DeepSeek.json @@ -7,7 +7,10 @@ "maxContext": 64000, "maxResponse": 8000, "quoteMaxToken": 60000, - "maxTemperature": 1.5, + "maxTemperature": 1, + "showTopP": true, + "responseFormatList": ["text", "json_object"], + "showStopSign": true, "vision": false, "toolChoice": true, "functionCall": false, @@ -42,7 +45,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true } ] } diff --git a/packages/service/core/ai/config/provider/Doubao.json b/packages/service/core/ai/config/provider/Doubao.json index f8f124083..1beb32ed7 100644 --- a/packages/service/core/ai/config/provider/Doubao.json +++ b/packages/service/core/ai/config/provider/Doubao.json @@ -8,6 +8,8 @@ "maxResponse": 4000, "quoteMaxToken": 32000, "maxTemperature": 1, + "showTopP": true, + "showStopSign": true, "vision": false, "toolChoice": true, "functionCall": false, @@ -30,6 +32,8 @@ "maxResponse": 4000, "quoteMaxToken": 32000, "maxTemperature": 1, + "showTopP": true, + "showStopSign": true, "vision": false, "toolChoice": true, "functionCall": false, @@ -52,6 +56,8 @@ "maxResponse": 12000, "quoteMaxToken": 256000, "maxTemperature": 1, + "showTopP": true, + "showStopSign": true, "vision": false, "toolChoice": true, "functionCall": false, @@ -74,6 +80,8 @@ "maxResponse": 4000, "quoteMaxToken": 32000, "maxTemperature": 1, + "showTopP": true, + "showStopSign": true, "vision": true, "toolChoice": true, "functionCall": false, @@ -96,6 +104,8 @@ "maxResponse": 4000, "quoteMaxToken": 4000, "maxTemperature": 1, + "showTopP": true, + "showStopSign": true, "vision": false, "toolChoice": true, "functionCall": false, @@ -118,6 +128,8 @@ "maxResponse": 4000, "quoteMaxToken": 32000, "maxTemperature": 1, + "showTopP": true, + "showStopSign": true, "vision": false, "toolChoice": true, "functionCall": false, @@ -153,7 +165,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "Doubao-vision-lite-32k", @@ -175,7 +189,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "Doubao-pro-4k", @@ -197,7 +213,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "Doubao-pro-32k", @@ -219,7 +237,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "Doubao-pro-128k", @@ -241,7 +261,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "Doubao-vision-pro-32k", @@ -263,21 +285,25 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "Doubao-embedding-large", "name": "Doubao-embedding-large", "defaultToken": 512, "maxToken": 4096, - "type": "embedding" + "type": "embedding", + "normalization": true }, { "model": "Doubao-embedding", "name": "Doubao-embedding", "defaultToken": 512, "maxToken": 4096, - "type": "embedding" + "type": "embedding", + "normalization": true } ] } diff --git a/packages/service/core/ai/config/provider/Ernie.json b/packages/service/core/ai/config/provider/Ernie.json index 0eaf78699..3d4062a5d 100644 --- a/packages/service/core/ai/config/provider/Ernie.json +++ b/packages/service/core/ai/config/provider/Ernie.json @@ -21,7 +21,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "ERNIE-4.0-Turbo-8K", @@ -43,7 +45,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "ERNIE-Lite-8K", @@ -65,7 +69,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "ERNIE-Speed-128K", @@ -87,7 +93,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "Embedding-V1", diff --git a/packages/service/core/ai/config/provider/Gemini.json b/packages/service/core/ai/config/provider/Gemini.json index a29dde0a7..715963e29 100644 --- a/packages/service/core/ai/config/provider/Gemini.json +++ b/packages/service/core/ai/config/provider/Gemini.json @@ -21,7 +21,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "gemini-1.5-pro", @@ -43,7 +45,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "gemini-2.0-flash-exp", @@ -65,7 +69,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "gemini-2.0-flash-thinking-exp-1219", @@ -87,7 +93,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "gemini-2.0-flash-thinking-exp-01-21", @@ -109,7 +117,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "gemini-exp-1206", @@ -131,7 +141,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "text-embedding-004", @@ -141,4 +153,4 @@ "type": "embedding" } ] -} +} \ No newline at end of file diff --git a/packages/service/core/ai/config/provider/Groq.json b/packages/service/core/ai/config/provider/Groq.json index 22fc70b49..5e1ef48ac 100644 --- a/packages/service/core/ai/config/provider/Groq.json +++ b/packages/service/core/ai/config/provider/Groq.json @@ -20,7 +20,9 @@ "customExtractPrompt": "", "usedInToolCall": true, "defaultConfig": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "llama-3.3-70b-versatile", @@ -41,7 +43,9 @@ "customExtractPrompt": "", "usedInToolCall": true, "defaultConfig": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true } ] } \ No newline at end of file diff --git a/packages/service/core/ai/config/provider/Hunyuan.json b/packages/service/core/ai/config/provider/Hunyuan.json index cf6a4317a..c85c4d344 100644 --- a/packages/service/core/ai/config/provider/Hunyuan.json +++ b/packages/service/core/ai/config/provider/Hunyuan.json @@ -21,7 +21,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "hunyuan-lite", @@ -43,7 +45,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "hunyuan-pro", @@ -65,7 +69,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "hunyuan-standard", @@ -87,7 +93,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "hunyuan-turbo-vision", @@ -109,7 +117,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "hunyuan-turbo", @@ -131,7 +141,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "hunyuan-vision", @@ -153,7 +165,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "hunyuan-embedding", diff --git a/packages/service/core/ai/config/provider/Intern.json b/packages/service/core/ai/config/provider/Intern.json index 45adf4a52..64f56e3d6 100644 --- a/packages/service/core/ai/config/provider/Intern.json +++ b/packages/service/core/ai/config/provider/Intern.json @@ -21,7 +21,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "internlm3-8b-instruct", @@ -43,7 +45,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true } ] } \ No newline at end of file diff --git a/packages/service/core/ai/config/provider/MiniMax.json b/packages/service/core/ai/config/provider/MiniMax.json index de0520088..9cf62e4d9 100644 --- a/packages/service/core/ai/config/provider/MiniMax.json +++ b/packages/service/core/ai/config/provider/MiniMax.json @@ -21,7 +21,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "abab6.5s-chat", @@ -43,7 +45,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "speech-01-turbo", @@ -237,4 +241,4 @@ "type": "tts" } ] -} +} \ No newline at end of file diff --git a/packages/service/core/ai/config/provider/MistralAI.json b/packages/service/core/ai/config/provider/MistralAI.json index 3d271db2a..3d60d8358 100644 --- a/packages/service/core/ai/config/provider/MistralAI.json +++ b/packages/service/core/ai/config/provider/MistralAI.json @@ -21,7 +21,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "ministral-8b-latest", @@ -43,7 +45,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "mistral-large-latest", @@ -65,7 +69,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "mistral-small-latest", @@ -87,7 +93,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true } ] } \ No newline at end of file diff --git a/packages/service/core/ai/config/provider/Moonshot.json b/packages/service/core/ai/config/provider/Moonshot.json index 9b733677c..796c529b8 100644 --- a/packages/service/core/ai/config/provider/Moonshot.json +++ b/packages/service/core/ai/config/provider/Moonshot.json @@ -21,7 +21,10 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true, + "responseFormatList": ["text", "json_object"] }, { "model": "moonshot-v1-32k", @@ -43,7 +46,10 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true, + "responseFormatList": ["text", "json_object"] }, { "model": "moonshot-v1-128k", @@ -65,7 +71,10 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true, + "responseFormatList": ["text", "json_object"] } ] } diff --git a/packages/service/core/ai/config/provider/OpenAI.json b/packages/service/core/ai/config/provider/OpenAI.json index e1c137390..324958f5c 100644 --- a/packages/service/core/ai/config/provider/OpenAI.json +++ b/packages/service/core/ai/config/provider/OpenAI.json @@ -9,7 +9,11 @@ "quoteMaxToken": 60000, "maxTemperature": 1.2, "showTopP": true, - "responseFormatList": ["text", "json_object", "json_schema"], + "responseFormatList": [ + "text", + "json_object", + "json_schema" + ], "showStopSign": true, "vision": true, "toolChoice": true, @@ -32,6 +36,13 @@ "maxResponse": 4000, "quoteMaxToken": 60000, "maxTemperature": 1.2, + "showTopP": true, + "responseFormatList": [ + "text", + "json_object", + "json_schema" + ], + "showStopSign": true, "vision": true, "toolChoice": true, "functionCall": true, @@ -71,7 +82,9 @@ "fieldMap": { "max_tokens": "max_completion_tokens" }, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "o1-mini", @@ -97,7 +110,9 @@ "fieldMap": { "max_tokens": "max_completion_tokens" }, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "o1", @@ -123,7 +138,9 @@ "fieldMap": { "max_tokens": "max_completion_tokens" }, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "o1-preview", @@ -149,7 +166,9 @@ "fieldMap": { "max_tokens": "max_completion_tokens" }, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "gpt-3.5-turbo", @@ -158,6 +177,8 @@ "maxResponse": 4000, "quoteMaxToken": 13000, "maxTemperature": 1.2, + "showTopP": true, + "showStopSign": true, "vision": false, "toolChoice": true, "functionCall": true, @@ -178,6 +199,8 @@ "maxResponse": 4000, "quoteMaxToken": 60000, "maxTemperature": 1.2, + "showTopP": true, + "showStopSign": true, "vision": true, "toolChoice": true, "functionCall": true, @@ -252,4 +275,4 @@ "type": "stt" } ] -} +} \ No newline at end of file diff --git a/packages/service/core/ai/config/provider/Qwen.json b/packages/service/core/ai/config/provider/Qwen.json index cde27ac13..c4c00efae 100644 --- a/packages/service/core/ai/config/provider/Qwen.json +++ b/packages/service/core/ai/config/provider/Qwen.json @@ -21,7 +21,10 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true, + "responseFormatList": ["text", "json_object"] }, { "model": "qwen-plus", @@ -43,7 +46,10 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true, + "responseFormatList": ["text", "json_object"] }, { "model": "qwen-vl-plus", @@ -63,7 +69,9 @@ "usedInQueryExtension": true, "customExtractPrompt": "", "usedInToolCall": true, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "qwen-max", @@ -85,7 +93,10 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true, + "responseFormatList": ["text", "json_object"] }, { "model": "qwen-vl-max", @@ -107,7 +118,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "qwen-coder-turbo", @@ -129,7 +142,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "qwen2.5-7b-instruct", @@ -151,7 +166,10 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true, + "responseFormatList": ["text", "json_object"] }, { "model": "qwen2.5-14b-instruct", @@ -173,7 +191,10 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true, + "responseFormatList": ["text", "json_object"] }, { "model": "qwen2.5-32b-instruct", @@ -195,7 +216,10 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true, + "responseFormatList": ["text", "json_object"] }, { "model": "qwen2.5-72b-instruct", @@ -217,7 +241,10 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true, + "responseFormatList": ["text", "json_object"] } ] } diff --git a/packages/service/core/ai/config/provider/Siliconflow.json b/packages/service/core/ai/config/provider/Siliconflow.json index f1e8a042a..1abaa846c 100644 --- a/packages/service/core/ai/config/provider/Siliconflow.json +++ b/packages/service/core/ai/config/provider/Siliconflow.json @@ -21,7 +21,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "Qwen/Qwen2-VL-72B-Instruct", @@ -42,7 +44,9 @@ "customExtractPrompt": "", "defaultSystemChatPrompt": "", "defaultConfig": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "deepseek-ai/DeepSeek-V2.5", @@ -64,7 +68,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "BAAI/bge-m3", @@ -201,4 +207,4 @@ "type": "rerank" } ] -} +} \ No newline at end of file diff --git a/packages/service/core/ai/config/provider/SparkDesk.json b/packages/service/core/ai/config/provider/SparkDesk.json index 095136850..0ea74643b 100644 --- a/packages/service/core/ai/config/provider/SparkDesk.json +++ b/packages/service/core/ai/config/provider/SparkDesk.json @@ -19,7 +19,9 @@ "customCQPrompt": "", "customExtractPrompt": "", "defaultSystemChatPrompt": "", - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "generalv3", @@ -39,7 +41,9 @@ "customCQPrompt": "", "customExtractPrompt": "", "defaultSystemChatPrompt": "", - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "pro-128k", @@ -59,7 +63,9 @@ "customCQPrompt": "", "customExtractPrompt": "", "defaultSystemChatPrompt": "", - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "generalv3.5", @@ -79,7 +85,9 @@ "customCQPrompt": "", "customExtractPrompt": "", "defaultSystemChatPrompt": "", - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "max-32k", @@ -101,7 +109,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "4.0Ultra", @@ -123,7 +133,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true } ] -} +} \ No newline at end of file diff --git a/packages/service/core/ai/config/provider/StepFun.json b/packages/service/core/ai/config/provider/StepFun.json index 87c896117..bfe2f766b 100644 --- a/packages/service/core/ai/config/provider/StepFun.json +++ b/packages/service/core/ai/config/provider/StepFun.json @@ -19,7 +19,9 @@ "customCQPrompt": "", "customExtractPrompt": "", "defaultSystemChatPrompt": "", - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "step-1-8k", @@ -39,7 +41,9 @@ "customCQPrompt": "", "customExtractPrompt": "", "defaultSystemChatPrompt": "", - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "step-1-32k", @@ -59,7 +63,9 @@ "customCQPrompt": "", "customExtractPrompt": "", "defaultSystemChatPrompt": "", - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "step-1-128k", @@ -79,7 +85,9 @@ "customCQPrompt": "", "customExtractPrompt": "", "defaultSystemChatPrompt": "", - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "step-1-256k", @@ -99,7 +107,9 @@ "customCQPrompt": "", "customExtractPrompt": "", "defaultSystemChatPrompt": "", - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "step-1o-vision-32k", @@ -119,7 +129,9 @@ "customCQPrompt": "", "customExtractPrompt": "", "defaultSystemChatPrompt": "", - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "step-1v-8k", @@ -139,7 +151,9 @@ "customCQPrompt": "", "customExtractPrompt": "", "defaultSystemChatPrompt": "", - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "step-1v-32k", @@ -159,7 +173,9 @@ "customCQPrompt": "", "customExtractPrompt": "", "defaultSystemChatPrompt": "", - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "step-2-mini", @@ -179,7 +195,9 @@ "customCQPrompt": "", "customExtractPrompt": "", "defaultSystemChatPrompt": "", - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "step-2-16k", @@ -199,7 +217,9 @@ "customCQPrompt": "", "customExtractPrompt": "", "defaultSystemChatPrompt": "", - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "step-2-16k-exp", @@ -219,7 +239,9 @@ "customCQPrompt": "", "customExtractPrompt": "", "defaultSystemChatPrompt": "", - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "step-tts-mini", @@ -305,4 +327,4 @@ "type": "tts" } ] -} +} \ No newline at end of file diff --git a/packages/service/core/ai/config/provider/Yi.json b/packages/service/core/ai/config/provider/Yi.json index b43a9ba90..36c95375e 100644 --- a/packages/service/core/ai/config/provider/Yi.json +++ b/packages/service/core/ai/config/provider/Yi.json @@ -21,7 +21,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true }, { "model": "yi-vision-v2", @@ -43,7 +45,9 @@ "usedInToolCall": true, "defaultConfig": {}, "fieldMap": {}, - "type": "llm" + "type": "llm", + "showTopP": true, + "showStopSign": true } ] } \ No newline at end of file diff --git a/packages/service/core/ai/embedding/index.ts b/packages/service/core/ai/embedding/index.ts index ec0650546..453f9b9d9 100644 --- a/packages/service/core/ai/embedding/index.ts +++ b/packages/service/core/ai/embedding/index.ts @@ -56,7 +56,14 @@ export async function getVectorsByText({ model, input, type }: GetVectorProps) { const [tokens, vectors] = await Promise.all([ countPromptTokens(input), - Promise.all(res.data.map((item) => unityDimensional(item.embedding))) + Promise.all( + res.data + .map((item) => unityDimensional(item.embedding)) + .map((item) => { + if (model.normalization) return normalization(item); + return item; + }) + ) ]); return { @@ -87,3 +94,15 @@ function unityDimensional(vector: number[]) { return resultVector.concat(zeroVector); } +// normalization processing +function normalization(vector: number[]) { + if (vector.some((item) => item > 1)) { + // Calculate the Euclidean norm (L2 norm) + const norm = Math.sqrt(vector.reduce((sum, val) => sum + val * val, 0)); + + // Normalize the vector by dividing each component by the norm + return vector.map((val) => val / norm); + } + + return vector; +} diff --git a/packages/web/i18n/en/account.json b/packages/web/i18n/en/account.json index 6290f70d1..4d6afa51b 100644 --- a/packages/web/i18n/en/account.json +++ b/packages/web/i18n/en/account.json @@ -46,6 +46,8 @@ "model.max_temperature": "Max temperature", "model.model_id": "Model ID", "model.model_id_tip": "The unique identifier of the model, that is, the value of the actual request to the service provider model, needs to correspond to the model in the OneAPI channel.", + "model.normalization": "Normalization processing", + "model.normalization_tip": "If the Embedding API does not normalize vector values, the switch can be enabled and the system will normalize.\n\nUnnormalized APIs, which are represented by the vector search score greater than 1.", "model.output_price": "Output price", "model.output_price_tip": "The language model output price. If this item is configured, the model comprehensive price will be invalid.", "model.param_name": "Parameter name", diff --git a/packages/web/i18n/zh-CN/account.json b/packages/web/i18n/zh-CN/account.json index 8604427c3..4d1538515 100644 --- a/packages/web/i18n/zh-CN/account.json +++ b/packages/web/i18n/zh-CN/account.json @@ -46,6 +46,8 @@ "model.max_temperature": "最大温度", "model.model_id": "模型ID", "model.model_id_tip": "模型的唯一标识,也就是实际请求到服务商model 的值,需要与 OneAPI 渠道中的模型对应。", + "model.normalization": "归一化处理", + "model.normalization_tip": "如果Embedding API 未对向量值进行归一化,可以启用该开关,系统会进行归一化处理。\n未归一化的 API,表现为向量检索得分会大于 1。", "model.output_price": "模型输出价格", "model.output_price_tip": "语言模型输出价格,如果配置了该项,则模型综合价格会失效", "model.param_name": "参数名", diff --git a/packages/web/i18n/zh-Hant/account.json b/packages/web/i18n/zh-Hant/account.json index b619ba6f1..1b0894537 100644 --- a/packages/web/i18n/zh-Hant/account.json +++ b/packages/web/i18n/zh-Hant/account.json @@ -45,6 +45,8 @@ "model.max_temperature": "最大溫度", "model.model_id": "模型ID", "model.model_id_tip": "模型的唯一標識,也就是實際請求到服務商model 的值,需要與 OneAPI 頻道中的模型對應。", + "model.normalization": "歸一化處理", + "model.normalization_tip": "如果Embedding API 未對向量值進行歸一化,可以啟用該開關,系統會進行歸一化處理。\n\n未歸一化的 API,表現為向量檢索得分會大於 1。", "model.output_price": "模型輸出價格", "model.output_price_tip": "語言模型輸出價格,如果配置了該項,則模型綜合價格會失效", "model.param_name": "參數名", diff --git a/projects/app/src/components/common/NextHead/index.tsx b/projects/app/src/components/common/NextHead/index.tsx index d6210cff4..6c8f9531a 100644 --- a/projects/app/src/components/common/NextHead/index.tsx +++ b/projects/app/src/components/common/NextHead/index.tsx @@ -1,6 +1,6 @@ import { LOGO_ICON } from '@fastgpt/global/common/system/constants'; import Head from 'next/head'; -import React, { useMemo } from 'react'; +import React, { useEffect, useMemo } from 'react'; const NextHead = ({ title, icon, desc }: { title?: string; icon?: string; desc?: string }) => { const formatIcon = useMemo(() => { @@ -11,6 +11,13 @@ const NextHead = ({ title, icon, desc }: { title?: string; icon?: string; desc?: return LOGO_ICON; }, [icon]); + useEffect(() => { + // Force update document title + if (title) { + document.title = title; + } + }, [title]); + return ( {title} diff --git a/projects/app/src/pageComponents/account/model/ModelConfigTable.tsx b/projects/app/src/pageComponents/account/model/ModelConfigTable.tsx index 7139eaf69..3984d2c60 100644 --- a/projects/app/src/pageComponents/account/model/ModelConfigTable.tsx +++ b/projects/app/src/pageComponents/account/model/ModelConfigTable.tsx @@ -816,6 +816,19 @@ const ModelEditModal = ({ )} {isEmbeddingModel && ( <> + + + + {t('account:model.normalization')} + + + + + + + + + diff --git a/projects/app/src/pages/_error.tsx b/projects/app/src/pages/_error.tsx index 1bd1ae34f..9aeb4b71d 100644 --- a/projects/app/src/pages/_error.tsx +++ b/projects/app/src/pages/_error.tsx @@ -28,12 +28,12 @@ function Error() { return ( {`出现未捕获的异常。 -1. 私有部署用户,90%由于配置文件不正确/模型未启用导致。 +1. 私有部署用户,90%由于配置文件不正确/模型未启用导致。请确保系统内每个系列模型至少有一个可用。 2. 部分系统不兼容相关API。大部分是苹果的safari 浏览器导致,可以尝试更换 chrome。 3. 请关闭浏览器翻译功能,部分翻译导致页面崩溃。 排除3后,打开控制台的 console 查看具体报错信息。 -如果提示 xxx undefined 的话,就是配置文件有错误,或者是缺少可用模型,请确保系统内每个系列模型至少有一个可用。 +如果提示 xxx undefined 的话,就是配置文件有错误,或者是缺少可用模型。 `} ); diff --git a/projects/app/src/pages/api/core/ai/model/test.ts b/projects/app/src/pages/api/core/ai/model/test.ts index 7d9fe56b9..54ddb9758 100644 --- a/projects/app/src/pages/api/core/ai/model/test.ts +++ b/projects/app/src/pages/api/core/ai/model/test.ts @@ -57,7 +57,9 @@ async function handler( export default NextAPI(handler); const testLLMModel = async (model: LLMModelItemType) => { - const ai = getAIApi({}); + const ai = getAIApi({ + timeout: 10000 + }); const requestBody = llmCompletionsBodyFormat( { model: model.model, @@ -93,7 +95,9 @@ const testEmbeddingModel = async (model: EmbeddingModelItemType) => { }; const testTTSModel = async (model: TTSModelType) => { - const ai = getAIApi(); + const ai = getAIApi({ + timeout: 10000 + }); await ai.audio.speech.create( { model: model.model, diff --git a/projects/app/src/pages/chat/share.tsx b/projects/app/src/pages/chat/share.tsx index 7f010f3e6..a9e2cebdb 100644 --- a/projects/app/src/pages/chat/share.tsx +++ b/projects/app/src/pages/chat/share.tsx @@ -241,7 +241,11 @@ const OutLink = (props: Props) => { return ( <> - +