diff --git a/docSite/assets/imgs/image-55.png b/docSite/assets/imgs/image-55.png new file mode 100644 index 000000000..537436f6e Binary files /dev/null and b/docSite/assets/imgs/image-55.png differ diff --git a/docSite/assets/imgs/image-56.png b/docSite/assets/imgs/image-56.png new file mode 100644 index 000000000..2b4fa299e Binary files /dev/null and b/docSite/assets/imgs/image-56.png differ diff --git a/docSite/assets/imgs/image-57.png b/docSite/assets/imgs/image-57.png new file mode 100644 index 000000000..9069593d6 Binary files /dev/null and b/docSite/assets/imgs/image-57.png differ diff --git a/docSite/assets/imgs/image-58.png b/docSite/assets/imgs/image-58.png new file mode 100644 index 000000000..3dbc8d803 Binary files /dev/null and b/docSite/assets/imgs/image-58.png differ diff --git a/docSite/content/zh-cn/docs/development/upgrading/4817.md b/docSite/content/zh-cn/docs/development/upgrading/4817.md index 63892cf80..5f3729c2a 100644 --- a/docSite/content/zh-cn/docs/development/upgrading/4817.md +++ b/docSite/content/zh-cn/docs/development/upgrading/4817.md @@ -12,4 +12,5 @@ weight: 807 1. 2. 新增 - LLM 模型参数支持关闭 max_tokens 和 temperature。 -3. 优化 - 知识库搜索参数,滑动条支持输入模式,可以更精准的控制。 \ No newline at end of file +3. 优化 - 知识库搜索参数,滑动条支持输入模式,可以更精准的控制。 +4. 优化 - 可用模型展示 \ No newline at end of file diff --git a/docSite/content/zh-cn/docs/shopping_cart/intro.md b/docSite/content/zh-cn/docs/shopping_cart/intro.md index 117144827..5b407bdbb 100644 --- a/docSite/content/zh-cn/docs/shopping_cart/intro.md +++ b/docSite/content/zh-cn/docs/shopping_cart/intro.md @@ -19,17 +19,20 @@ FastGPT 商业版是基于 FastGPT 开源版的增强版本,增加了一些独 | 应用管理与高级编排 | ✅ | ✅ | ✅ | | 文档知识库 | ✅ | ✅ | ✅ | | 外部使用 | ✅ | ✅ | ✅ | +| API 知识库 | ✅ | ✅ | ✅ | | 最大应用数量 | 500 | 无限制 | 由付费套餐决定 | | 最大知识库数量(单个知识库内容无限制) | 30 | 无限制 | 由付费套餐决定 | | 自定义版权信息 | ❌ | ✅ | 设计中 | | 多租户与支付 | ❌ | ✅ | ✅ | -| 团队空间 | ❌ | ✅ | ✅ | +| 团队空间 & 权限 | ❌ | ✅ | ✅ | | 应用发布安全配置 | ❌ | ✅ | ✅ | | 内容审核 | ❌ | ✅ | ✅ | | web站点同步 | ❌ | ✅ | ✅ | -| 管理后台 | ❌ | ✅ | 不需要 | +| 主流文档库接入(目前支持:语雀、飞书) | ❌ | ✅ | ✅ | | 增强训练模式 | ❌ | ✅ | ✅ | | 第三方应用快速接入(飞书、公众号) | ❌ | ✅ | ✅ | +| 管理后台 | ❌ | ✅ | 不需要 | +| SSO 登录(可自定义,也可使用内置:Github、公众号、钉钉、谷歌等) | ❌ | ✅ | 不需要 | | 图片知识库 | ❌ | 设计中 | 设计中 | | 对话日志运营分析 | ❌ | 设计中 | 设计中 | | 完整商业授权 | ❌ | ✅ | ✅ | @@ -50,8 +53,8 @@ FastGPT 商业版软件根据不同的部署方式,分为 3 类收费模式。 {{< table "table-hover table-striped-columns" >}} | 部署方式 | 特有服务 | 上线时长 | 标品价格 | | ---- | ---- | ---- | ---- | -| Sealos全托管 | 1. 有效期内免费升级。2. 免运维服务&数据库。 | 半天 | 5000元起/月(3个月起)或50000元起/年 | -| 自有服务器部署 | 1. 6个版本的升级服务。 | 14天内 | 具体价格可[联系咨询](https://fael3z0zfze.feishu.cn/share/base/form/shrcnRxj3utrzjywsom96Px4sud) | +| Sealos全托管 | 1. 有效期内免费升级。2. 免运维服务&数据库。 | 半天 | 6000元起/月(3个月起)或60000元起/年 | +| 自有服务器部署 | 1. 6个版本免费升级支持。 | 14天内 | 具体价格可[联系咨询](https://fael3z0zfze.feishu.cn/share/base/form/shrcnRxj3utrzjywsom96Px4sud) | {{< /table >}} {{% alert icon="🤖 " context="success" %}} @@ -62,6 +65,10 @@ FastGPT 商业版软件根据不同的部署方式,分为 3 类收费模式。 - 高可用版适合对外提供在线服务,包含可视化监控、多副本、负载均衡、数据库自动备份等生产环境的基础设施。 {{% /alert %}} +## 联系方式 + +请填写[咨询问卷](https://fael3z0zfze.feishu.cn/share/base/form/shrcnRxj3utrzjywsom96Px4sud),我们会尽快与您联系。 + ## 技术支持 @@ -79,9 +86,6 @@ FastGPT 商业版软件根据不同的部署方式,分为 3 类收费模式。 跨版本更新或复杂更新可参考文档自行更新;或付费支持,标准与技术服务费一致。 -## 联系方式 - -请填写[咨询问卷](https://fael3z0zfze.feishu.cn/share/base/form/shrcnRxj3utrzjywsom96Px4sud),我们会尽快与您联系。 ## QA @@ -95,8 +99,14 @@ FastGPT 商业版软件根据不同的部署方式,分为 3 类收费模式。 可以修改开源版部分代码,不支持修改商业版镜像。完整版本=开源版+商业版镜像,所以是可以修改部分内容的。但是如果二开了,后续则需要自己进行代码合并升级。 -## Sealos 费用 +### Sealos 运行费用 Sealos 云服务属于按量计费,下面是它的价格表: - + + +## 管理后台部分截图 + +| | | | +| ---- | ---- | ---- | +|  |  |  | \ No newline at end of file diff --git a/packages/global/common/system/types/index.d.ts b/packages/global/common/system/types/index.d.ts index 0b0188f5e..c04276961 100644 --- a/packages/global/common/system/types/index.d.ts +++ b/packages/global/common/system/types/index.d.ts @@ -5,7 +5,7 @@ import type { LLMModelItemType, VectorModelItemType, AudioSpeechModels, - WhisperModelType, + STTModelType, ReRankModelItemType } from '../../../core/ai/model.d'; import { SubTypeEnum } from '../../../support/wallet/sub/constants'; @@ -27,7 +27,7 @@ export type FastGPTConfigFileType = { vectorModels: VectorModelItemType[]; reRankModels: ReRankModelItemType[]; audioSpeechModels: AudioSpeechModelType[]; - whisperModel: WhisperModelType; + whisperModel: STTModelType; }; export type FastGPTFeConfigsType = { diff --git a/packages/global/core/ai/model.d.ts b/packages/global/core/ai/model.d.ts index 38687fbc2..e9620f95f 100644 --- a/packages/global/core/ai/model.d.ts +++ b/packages/global/core/ai/model.d.ts @@ -57,13 +57,15 @@ export type ReRankModelItemType = { }; export type AudioSpeechModelType = { + provider: ModelProviderIdType; model: string; name: string; charsPointsPrice: number; voices: { label: string; value: string; bufferId: string }[]; }; -export type WhisperModelType = { +export type STTModelType = { + provider: ModelProviderIdType; model: string; name: string; charsPointsPrice: number; // 60s = n points diff --git a/packages/global/core/ai/model.ts b/packages/global/core/ai/model.ts index ff6d07f59..4a40c83c5 100644 --- a/packages/global/core/ai/model.ts +++ b/packages/global/core/ai/model.ts @@ -1,4 +1,5 @@ -import type { LLMModelItemType, VectorModelItemType } from './model.d'; +import { i18nT } from '../../../web/i18n/utils'; +import type { LLMModelItemType, STTModelType, VectorModelItemType } from './model.d'; import { getModelProvider, ModelProviderIdType } from './provider'; export const defaultQAModels: LLMModelItemType[] = [ @@ -35,6 +36,13 @@ export const defaultVectorModels: VectorModelItemType[] = [ } ]; +export const defaultWhisperModel: STTModelType = { + provider: 'OpenAI', + model: 'whisper-1', + name: 'whisper-1', + charsPointsPrice: 0 +}; + export const getModelFromList = ( modelList: { provider: ModelProviderIdType; name: string; model: string }[], model: string @@ -46,3 +54,16 @@ export const getModelFromList = ( avatar: provider.avatar }; }; + +export enum ModelTypeEnum { + chat = 'chat', + embedding = 'embedding', + tts = 'tts', + stt = 'stt' +} +export const modelTypeList = [ + { label: i18nT('common:model.type.chat'), value: ModelTypeEnum.chat }, + { label: i18nT('common:model.type.embedding'), value: ModelTypeEnum.embedding }, + { label: i18nT('common:model.type.tts'), value: ModelTypeEnum.tts }, + { label: i18nT('common:model.type.stt'), value: ModelTypeEnum.stt } +]; diff --git a/packages/global/core/ai/provider.ts b/packages/global/core/ai/provider.ts index 8ca7bfcaa..589371845 100644 --- a/packages/global/core/ai/provider.ts +++ b/packages/global/core/ai/provider.ts @@ -5,6 +5,7 @@ export type ModelProviderIdType = | 'Claude' | 'Gemini' | 'MistralAI' + | 'Groq' | 'Qwen' | 'Doubao' | 'ChatGLM' @@ -44,7 +45,12 @@ export const ModelProviderList: ModelProviderType[] = [ { id: 'MistralAI', name: 'MistralAI', - avatar: 'model/huggingface' + avatar: 'model/mistral' + }, + { + id: 'Groq', + name: 'Groq', + avatar: 'model/groq' }, { id: 'Qwen', @@ -113,7 +119,7 @@ export const ModelProviderList: ModelProviderType[] = [ } ]; export const ModelProviderMap = Object.fromEntries( - ModelProviderList.map((item) => [item.id, item]) + ModelProviderList.map((item, index) => [item.id, { ...item, order: index }]) ); export const getModelProvider = (provider: ModelProviderIdType) => { diff --git a/packages/service/common/system/config/controller.ts b/packages/service/common/system/config/controller.ts index 962be6b37..aa79f916d 100644 --- a/packages/service/common/system/config/controller.ts +++ b/packages/service/common/system/config/controller.ts @@ -4,7 +4,12 @@ import { FastGPTConfigFileType } from '@fastgpt/global/common/system/types'; import { FastGPTProUrl } from '../constants'; export const getFastGPTConfigFromDB = async () => { - if (!FastGPTProUrl) return {} as FastGPTConfigFileType; + if (!FastGPTProUrl) { + return { + config: {} as FastGPTConfigFileType, + configId: undefined + }; + } const res = await MongoSystemConfigs.findOne({ type: SystemConfigsTypeEnum.fastgpt @@ -14,5 +19,8 @@ export const getFastGPTConfigFromDB = async () => { const config = res?.value || {}; - return config as FastGPTConfigFileType; + return { + configId: res ? String(res._id) : undefined, + config: config as FastGPTConfigFileType + }; }; diff --git a/packages/service/core/ai/utils.ts b/packages/service/core/ai/utils.ts index 92502b183..aad1cb1ef 100644 --- a/packages/service/core/ai/utils.ts +++ b/packages/service/core/ai/utils.ts @@ -39,8 +39,6 @@ export const computedTemperature = ({ model: LLMModelItemType; temperature: number; }) => { - if (temperature < 1) return temperature; - temperature = +(model.maxTemperature * (temperature / 10)).toFixed(2); temperature = Math.max(temperature, 0.01); diff --git a/packages/service/core/plugin/type.d.ts b/packages/service/core/plugin/type.d.ts index 3c66d0c85..d018bea6e 100644 --- a/packages/service/core/plugin/type.d.ts +++ b/packages/service/core/plugin/type.d.ts @@ -2,6 +2,5 @@ import { PluginTemplateType } from '@fastgpt/global/core/plugin/type.d'; import { SystemPluginTemplateItemType } from '@fastgpt/global/core/workflow/type'; declare global { - var communityPluginsV1: PluginTemplateType[]; var communityPlugins: SystemPluginTemplateItemType[]; } diff --git a/packages/service/type.d.ts b/packages/service/type.d.ts index ad8e11399..4ed702348 100644 --- a/packages/service/type.d.ts +++ b/packages/service/type.d.ts @@ -2,7 +2,7 @@ import { FastGPTFeConfigsType, SystemEnvType } from '@fastgpt/global/common/syst import { AudioSpeechModelType, ReRankModelItemType, - WhisperModelType, + STTModelType, VectorModelItemType, LLMModelItemType } from '@fastgpt/global/core/ai/model.d'; @@ -12,6 +12,7 @@ import { Worker } from 'worker_threads'; import { TemplateMarketItemType } from '@fastgpt/global/core/workflow/type'; declare global { + var systemInitBufferId: string | undefined; var systemVersion: string; var feConfigs: FastGPTFeConfigsType; var systemEnv: SystemEnvType; @@ -20,7 +21,7 @@ declare global { var llmModels: LLMModelItemType[]; var vectorModels: VectorModelItemType[]; var audioSpeechModels: AudioSpeechModelType[]; - var whisperModel: WhisperModelType; + var whisperModel: STTModelType; var reRankModels: ReRankModelItemType[]; var workerPoll: Record; diff --git a/packages/web/components/common/Icon/constants.ts b/packages/web/components/common/Icon/constants.ts index 51c616371..2edf4cb6d 100644 --- a/packages/web/components/common/Icon/constants.ts +++ b/packages/web/components/common/Icon/constants.ts @@ -56,7 +56,7 @@ export const iconPaths = { 'common/loading': () => import('./icons/common/loading.svg'), 'common/logLight': () => import('./icons/common/logLight.svg'), 'common/microsoft': () => import('./icons/common/microsoft.svg'), - 'common/modal': () => import('./icons/common/modal.svg'), + 'common/model': () => import('./icons/common/model.svg'), 'common/monitor': () => import('./icons/common/monitor.svg'), 'common/more': () => import('./icons/common/more.svg'), 'common/moreFill': () => import('./icons/common/moreFill.svg'), @@ -348,9 +348,11 @@ export const iconPaths = { 'model/doubao': () => import('./icons/model/doubao.svg'), 'model/ernie': () => import('./icons/model/ernie.svg'), 'model/gemini': () => import('./icons/model/gemini.svg'), + 'model/groq': () => import('./icons/model/groq.svg'), 'model/huggingface': () => import('./icons/model/huggingface.svg'), 'model/hunyuan': () => import('./icons/model/hunyuan.svg'), 'model/minimax': () => import('./icons/model/minimax.svg'), + 'model/mistral': () => import('./icons/model/mistral.svg'), 'model/moonshot': () => import('./icons/model/moonshot.svg'), 'model/ollama': () => import('./icons/model/ollama.svg'), 'model/openai': () => import('./icons/model/openai.svg'), @@ -395,7 +397,6 @@ export const iconPaths = { 'support/team/key': () => import('./icons/support/team/key.svg'), 'support/team/memberLight': () => import('./icons/support/team/memberLight.svg'), 'support/usage/usageRecordLight': () => import('./icons/support/usage/usageRecordLight.svg'), - 'support/user/individuation': () => import('./icons/support/user/individuation.svg'), 'support/user/informLight': () => import('./icons/support/user/informLight.svg'), 'support/user/userFill': () => import('./icons/support/user/userFill.svg'), 'support/user/userLight': () => import('./icons/support/user/userLight.svg'), diff --git a/packages/web/components/common/Icon/icons/common/modal.svg b/packages/web/components/common/Icon/icons/common/model.svg similarity index 100% rename from packages/web/components/common/Icon/icons/common/modal.svg rename to packages/web/components/common/Icon/icons/common/model.svg diff --git a/packages/web/components/common/Icon/icons/model/gemini.svg b/packages/web/components/common/Icon/icons/model/gemini.svg index 4545c8331..e96d01953 100644 --- a/packages/web/components/common/Icon/icons/model/gemini.svg +++ b/packages/web/components/common/Icon/icons/model/gemini.svg @@ -1,10 +1,9 @@ - - + + - - - - - + + + + diff --git a/packages/web/components/common/Icon/icons/model/groq.svg b/packages/web/components/common/Icon/icons/model/groq.svg new file mode 100644 index 000000000..4b3f1c50d --- /dev/null +++ b/packages/web/components/common/Icon/icons/model/groq.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/packages/web/components/common/Icon/icons/model/hunyuan.svg b/packages/web/components/common/Icon/icons/model/hunyuan.svg index d7e6fc655..ec2157e28 100644 --- a/packages/web/components/common/Icon/icons/model/hunyuan.svg +++ b/packages/web/components/common/Icon/icons/model/hunyuan.svg @@ -1,13 +1 @@ - - - - - - - - - - - - - + \ No newline at end of file diff --git a/packages/web/components/common/Icon/icons/model/mistral.svg b/packages/web/components/common/Icon/icons/model/mistral.svg new file mode 100644 index 000000000..735981b91 --- /dev/null +++ b/packages/web/components/common/Icon/icons/model/mistral.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/web/components/common/Icon/icons/model/ollama.svg b/packages/web/components/common/Icon/icons/model/ollama.svg index c5f4f94a1..74de384a3 100644 --- a/packages/web/components/common/Icon/icons/model/ollama.svg +++ b/packages/web/components/common/Icon/icons/model/ollama.svg @@ -1,119 +1,5 @@ - - - - + + + + + \ No newline at end of file diff --git a/packages/web/components/common/Icon/icons/model/yi.svg b/packages/web/components/common/Icon/icons/model/yi.svg index 4607c3dad..ebc945d71 100644 --- a/packages/web/components/common/Icon/icons/model/yi.svg +++ b/packages/web/components/common/Icon/icons/model/yi.svg @@ -1,10 +1,14 @@ - - - - - - + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/web/components/common/Icon/icons/support/user/individuation.svg b/packages/web/components/common/Icon/icons/support/user/individuation.svg deleted file mode 100644 index 63b6af4f4..000000000 --- a/packages/web/components/common/Icon/icons/support/user/individuation.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - \ No newline at end of file diff --git a/packages/web/components/common/MySelect/index.tsx b/packages/web/components/common/MySelect/index.tsx index 36a3eb59f..7d503d21b 100644 --- a/packages/web/components/common/MySelect/index.tsx +++ b/packages/web/components/common/MySelect/index.tsx @@ -110,7 +110,7 @@ const MySelect = ( px={3} rightIcon={} variant={'whitePrimaryOutline'} - size={'lg'} + size={'md'} fontSize={'sm'} textAlign={'left'} _active={{ diff --git a/packages/web/i18n/en/account.json b/packages/web/i18n/en/account.json index aa449be12..28f3369ad 100644 --- a/packages/web/i18n/en/account.json +++ b/packages/web/i18n/en/account.json @@ -3,6 +3,7 @@ "bills_and_invoices": "Bills", "confirm_logout": "Confirm to log out?", "logout": "Sign out", + "model_provider": "Model Provider", "notifications": "Notify", "personal_information": "Personal", "personalization": "Personalization", diff --git a/packages/web/i18n/en/account_individuation.json b/packages/web/i18n/en/account_setting.json similarity index 100% rename from packages/web/i18n/en/account_individuation.json rename to packages/web/i18n/en/account_setting.json diff --git a/packages/web/i18n/en/common.json b/packages/web/i18n/en/common.json index 1ff88f10a..7b04bd544 100644 --- a/packages/web/i18n/en/common.json +++ b/packages/web/i18n/en/common.json @@ -896,6 +896,15 @@ "item_name": "Field Name", "just_now": "just", "key_repetition": "Key Repetition", + "model.billing": "Billing", + "model.model_type": "Model type", + "model.name": "Model name", + "model.provider": "Provider", + "model.search_name_placeholder": "Search by model name", + "model.type.chat": "language model", + "model.type.embedding": "Embedding", + "model.type.stt": "speech recognition", + "model.type.tts": "TTS", "model_baichuan": "Baichuan", "model_chatglm": "ChatGLM", "model_doubao": "Doubao", diff --git a/packages/web/i18n/en/user.json b/packages/web/i18n/en/user.json index 473a84cf9..5f2ba68ee 100644 --- a/packages/web/i18n/en/user.json +++ b/packages/web/i18n/en/user.json @@ -22,7 +22,6 @@ "delete.failed": "Delete failed", "delete.success": "Delete successfully", "has_chosen": "Selected", - "individuation": "Individuation", "login.error": "Login Error", "login.password_condition": "Password can be up to 60 characters", "login.success": "Login Successful", diff --git a/packages/web/i18n/zh-CN/account.json b/packages/web/i18n/zh-CN/account.json index 5e4b48847..4da8699f1 100644 --- a/packages/web/i18n/zh-CN/account.json +++ b/packages/web/i18n/zh-CN/account.json @@ -1,12 +1,13 @@ { - "personal_information": "个人信息", - "usage_records": "使用记录", - "bills_and_invoices": "账单与发票", - "promotion_records": "促销记录", "api_key": "API 密钥", - "personalization": "个性化", - "notifications": "通知", - "logout": "登出", + "bills_and_invoices": "账单与发票", "confirm_logout": "确认退出登录?", - "team": "团队管理" + "logout": "登出", + "model_provider": "模型提供商", + "notifications": "通知", + "personal_information": "个人信息", + "personalization": "个性化", + "promotion_records": "促销记录", + "team": "团队管理", + "usage_records": "使用记录" } diff --git a/packages/web/i18n/zh-CN/account_individuation.json b/packages/web/i18n/zh-CN/account_setting.json similarity index 100% rename from packages/web/i18n/zh-CN/account_individuation.json rename to packages/web/i18n/zh-CN/account_setting.json diff --git a/packages/web/i18n/zh-CN/common.json b/packages/web/i18n/zh-CN/common.json index 495d1f7ba..f120ed2e7 100644 --- a/packages/web/i18n/zh-CN/common.json +++ b/packages/web/i18n/zh-CN/common.json @@ -895,13 +895,22 @@ "item_name": "字段名", "just_now": "刚刚", "key_repetition": "key 重复", + "model.billing": "模型计费", + "model.model_type": "模型类型", + "model.name": "模型名", + "model.provider": "模型提供商", + "model.search_name_placeholder": "根据模型名搜索", + "model.type.chat": "语言模型", + "model.type.embedding": "索引模型", + "model.type.stt": "语音识别", + "model.type.tts": "语音合成", "model_baichuan": "百川智能", "model_chatglm": "ChatGLM", "model_doubao": "豆包", "model_ernie": "文心一言", "model_hunyuan": "腾讯混元", "model_moonshot": "月之暗面", - "model_other": "自定义", + "model_other": "其他", "model_qwen": "阿里千问", "model_sparkdesk": "讯飞星火", "model_yi": "零一万物", diff --git a/packages/web/i18n/zh-CN/user.json b/packages/web/i18n/zh-CN/user.json index 253c92b94..0c3e50126 100644 --- a/packages/web/i18n/zh-CN/user.json +++ b/packages/web/i18n/zh-CN/user.json @@ -22,7 +22,6 @@ "delete.failed": "删除失败", "delete.success": "删除成功", "has_chosen": "已选择", - "individuation": "个性化", "login.error": "登录异常", "login.password_condition": "密码最多 60 位", "login.success": "登录成功", diff --git a/packages/web/i18n/zh-Hant/account.json b/packages/web/i18n/zh-Hant/account.json index 28ba36be2..82406e99a 100644 --- a/packages/web/i18n/zh-Hant/account.json +++ b/packages/web/i18n/zh-Hant/account.json @@ -3,6 +3,7 @@ "bills_and_invoices": "帳單與發票", "confirm_logout": "確認登出登入?", "logout": "登出", + "model_provider": "模型提供者", "notifications": "通知", "personal_information": "個人資訊", "personalization": "個人化", diff --git a/packages/web/i18n/zh-Hant/account_individuation.json b/packages/web/i18n/zh-Hant/account_setting.json similarity index 100% rename from packages/web/i18n/zh-Hant/account_individuation.json rename to packages/web/i18n/zh-Hant/account_setting.json diff --git a/packages/web/i18n/zh-Hant/common.json b/packages/web/i18n/zh-Hant/common.json index 4fc5bd9a0..e9f692fc1 100644 --- a/packages/web/i18n/zh-Hant/common.json +++ b/packages/web/i18n/zh-Hant/common.json @@ -897,13 +897,21 @@ "item_name": "欄位名稱", "just_now": "剛剛", "key_repetition": "鍵值重複", + "model.billing": "模型計費", + "model.model_type": "模型類型", + "model.name": "模型名", + "model.provider": "模型提供者", + "model.search_name_placeholder": "根據模型名搜尋", + "model.type.chat": "語言模型", + "model.type.stt": "語音辨識", + "model.type.tts": "語音合成", "model_baichuan": "百川智能", "model_chatglm": "ChatGLM", "model_doubao": "豆包", "model_ernie": "文心一言", "model_hunyuan": "騰訊混元", "model_moonshot": "月之暗面", - "model_other": "自訂", + "model_other": "其他", "model_qwen": "阿里千問", "model_sparkdesk": "訊飛星火", "model_yi": "零一萬物", diff --git a/packages/web/i18n/zh-Hant/user.json b/packages/web/i18n/zh-Hant/user.json index ecc27df0f..f743d765a 100644 --- a/packages/web/i18n/zh-Hant/user.json +++ b/packages/web/i18n/zh-Hant/user.json @@ -22,7 +22,6 @@ "delete.failed": "刪除失敗", "delete.success": "刪除成功", "has_chosen": "已選擇", - "individuation": "個人化", "login.error": "登入失敗", "login.password_condition": "密碼最多可輸入 60 個字元", "login.success": "登入成功", diff --git a/packages/web/types/i18next.d.ts b/packages/web/types/i18next.d.ts index 3f6347c0e..a13ce1c1b 100644 --- a/packages/web/types/i18next.d.ts +++ b/packages/web/types/i18next.d.ts @@ -3,7 +3,7 @@ import account_team from '../i18n/zh-CN/account_team.json'; import account from '../i18n/zh-CN/account.json'; import account_promotion from '../i18n/zh-CN/account_promotion.json'; import account_inform from '../i18n/zh-CN/account_inform.json'; -import account_individuation from '../i18n/zh-CN/account_individuation.json'; +import account_setting from '../i18n/zh-CN/account_setting.json'; import account_apikey from '../i18n/zh-CN/account_apikey.json'; import account_bill from '../i18n/zh-CN/account_bill.json'; import account_usage from '../i18n/zh-CN/account_usage.json'; @@ -32,7 +32,7 @@ export interface I18nNamespaces { account_usage: typeof account_usage; account_bill: typeof account_bill; account_apikey: typeof account_apikey; - account_individuation: typeof account_individuation; + account_setting: typeof account_setting; account_inform: typeof account_inform; account_promotion: typeof account_promotion; account: typeof account; @@ -66,7 +66,7 @@ declare module 'i18next' { 'account_usage', 'account_bill', 'account_apikey', - 'account_individuation', + 'account_setting', 'account_inform', 'account_promotion', 'account', diff --git a/projects/app/src/components/Layout/index.tsx b/projects/app/src/components/Layout/index.tsx index bb4773604..b48a9fd8d 100644 --- a/projects/app/src/components/Layout/index.tsx +++ b/projects/app/src/components/Layout/index.tsx @@ -61,7 +61,7 @@ const Layout = ({ children }: { children: JSX.Element }) => { // System hook const { data, refetch: refetchUnRead } = useQuery(['getUnreadCount'], getUnreadCount, { enabled: !!userInfo && !!feConfigs.isPlus, - refetchInterval: 10000 + refetchInterval: 30000 }); const unread = data?.unReadCount || 0; const importantInforms = data?.importantInforms || []; diff --git a/projects/app/src/components/Layout/navbar.tsx b/projects/app/src/components/Layout/navbar.tsx index 509d8775c..ad714621e 100644 --- a/projects/app/src/components/Layout/navbar.tsx +++ b/projects/app/src/components/Layout/navbar.tsx @@ -83,9 +83,10 @@ const Navbar = ({ unread }: { unread: number }) => { '/account/team', '/account/usage', '/account/apikey', - '/account/individuation', + '/account/setting', '/account/inform', - '/account/promotion' + '/account/promotion', + '/account/model' ] } ], diff --git a/projects/app/src/components/Layout/navbarPhone.tsx b/projects/app/src/components/Layout/navbarPhone.tsx index 2da7f5eb2..534d55555 100644 --- a/projects/app/src/components/Layout/navbarPhone.tsx +++ b/projects/app/src/components/Layout/navbarPhone.tsx @@ -55,9 +55,10 @@ const NavbarPhone = ({ unread }: { unread: number }) => { '/account/team', '/account/usage', '/account/apikey', - '/account/individuation', + '/account/setting', '/account/inform', - '/account/promotion' + '/account/promotion', + '/account/model' ], unread } diff --git a/projects/app/src/components/Select/AIModelSelector.tsx b/projects/app/src/components/Select/AIModelSelector.tsx index 7d012e40b..b7e146fff 100644 --- a/projects/app/src/components/Select/AIModelSelector.tsx +++ b/projects/app/src/components/Select/AIModelSelector.tsx @@ -12,8 +12,8 @@ import { ModelProviderList } from '@fastgpt/global/core/ai/provider'; import MultipleRowSelect from '@fastgpt/web/components/common/MySelect/MultipleRowSelect'; import { getModelFromList } from '@fastgpt/global/core/ai/model'; -const AiPointsModal = dynamic(() => - import('@/pages/price/components/Points').then((mod) => mod.AiPointsModal) +const ModelPriceModal = dynamic(() => + import('@/components/core/ai/ModelTable').then((mod) => mod.ModelPriceModal) ); type Props = SelectProps & { @@ -103,7 +103,7 @@ const OneRowSelector = ({ list, onchange, disableTip, ...props }: Props) => { /> - {isOpenAiPointsModal && } + {isOpenAiPointsModal && } ); }; @@ -212,7 +212,7 @@ const MultipleRowSelector = ({ list, onchange, disableTip, ...props }: Props) => /> - {isOpenAiPointsModal && } + {isOpenAiPointsModal && } ); }; diff --git a/projects/app/src/components/core/ai/AISettingModal/index.tsx b/projects/app/src/components/core/ai/AISettingModal/index.tsx index b20cd106f..f36ac74b9 100644 --- a/projects/app/src/components/core/ai/AISettingModal/index.tsx +++ b/projects/app/src/components/core/ai/AISettingModal/index.tsx @@ -33,8 +33,8 @@ import MyIcon from '@fastgpt/web/components/common/Icon'; import dynamic from 'next/dynamic'; import InputSlider from '@fastgpt/web/components/common/MySlider/InputSlider'; -const AiPointsModal = dynamic(() => - import('@/pages/price/components/Points').then((mod) => mod.AiPointsModal) +const ModelPriceModal = dynamic(() => + import('@/components/core/ai/ModelTable').then((mod) => mod.ModelPriceModal) ); const FlexItemStyles: FlexProps = { @@ -328,7 +328,7 @@ const AIChatSettingsModal = ({ - {isOpenAiPointsModal && } + {isOpenAiPointsModal && } ); }; diff --git a/projects/app/src/components/core/ai/ModelTable/index.tsx b/projects/app/src/components/core/ai/ModelTable/index.tsx new file mode 100644 index 000000000..17a80675b --- /dev/null +++ b/projects/app/src/components/core/ai/ModelTable/index.tsx @@ -0,0 +1,251 @@ +import { + Box, + Flex, + HStack, + ModalBody, + Table, + TableContainer, + Tbody, + Td, + Th, + Thead, + Tr +} from '@chakra-ui/react'; +import MyModal from '@fastgpt/web/components/common/MyModal'; +import { useTranslation } from 'next-i18next'; +import React, { useMemo, useRef, useState } from 'react'; +import { + ModelProviderList, + ModelProviderIdType, + getModelProvider +} from '@fastgpt/global/core/ai/provider'; +import MySelect from '@fastgpt/web/components/common/MySelect'; +import { modelTypeList, ModelTypeEnum } from '@fastgpt/global/core/ai/model'; +import SearchInput from '@fastgpt/web/components/common/Input/SearchInput'; +import { useSystemStore } from '@/web/common/system/useSystemStore'; +import Avatar from '@fastgpt/web/components/common/Avatar'; +import MyTag from '@fastgpt/web/components/common/Tag/index'; +import MyTooltip from '@fastgpt/web/components/common/MyTooltip'; + +const ModelTable = () => { + const { t } = useTranslation(); + const [provider, setProvider] = useState(''); + const providerList = useRef<{ label: any; value: ModelProviderIdType | '' }[]>([ + { label: t('common:common.All'), value: '' }, + ...ModelProviderList.map((item) => ({ + label: ( + + + {t(item.name as any)} + + ), + value: item.id + })) + ]); + + const [modelType, setModelType] = useState(''); + const selectModelTypeList = useRef<{ label: string; value: ModelTypeEnum | '' }[]>([ + { label: t('common:common.All'), value: '' }, + ...modelTypeList.map((item) => ({ label: t(item.label), value: item.value })) + ]); + + const [search, setSearch] = useState(''); + + const { llmModelList, audioSpeechModelList, vectorModelList, whisperModel } = useSystemStore(); + + const modelList = useMemo(() => { + const formatLLMModelList = llmModelList.map((item) => ({ + ...item, + typeLabel: t('common:model.type.chat'), + priceLabel: ( + + + {item.charsPointsPrice} + + {`${t('common:support.wallet.subscription.point')} / 1K Tokens`} + + ), + tagColor: 'blue' + })); + const formatVectorModelList = vectorModelList.map((item) => ({ + ...item, + typeLabel: t('common:model.type.embedding'), + priceLabel: ( + + + {item.charsPointsPrice} + + {` ${t('common:support.wallet.subscription.point')} / 1K Tokens`} + + ), + tagColor: 'yellow' + })); + const formatAudioSpeechModelList = audioSpeechModelList.map((item) => ({ + ...item, + typeLabel: t('common:model.type.tts'), + priceLabel: ( + + + {item.charsPointsPrice} + + {` ${t('common:support.wallet.subscription.point')} / 1K ${t('common:unit.character')}`} + + ), + tagColor: 'green' + })); + const formatWhisperModel = { + ...whisperModel, + typeLabel: t('common:model.type.stt'), + priceLabel: ( + + + {whisperModel.charsPointsPrice} + + {` ${t('common:support.wallet.subscription.point')} / 60${t('common:unit.seconds')}`} + + ), + tagColor: 'purple' + }; + + const list = (() => { + if (modelType === ModelTypeEnum.chat) return formatLLMModelList; + if (modelType === ModelTypeEnum.embedding) return formatVectorModelList; + if (modelType === ModelTypeEnum.tts) return formatAudioSpeechModelList; + if (modelType === ModelTypeEnum.stt) return [formatWhisperModel]; + + return [ + ...formatLLMModelList, + ...formatVectorModelList, + ...formatAudioSpeechModelList, + formatWhisperModel + ]; + })(); + const formatList = list.map((item) => { + const provider = getModelProvider(item.provider); + return { + name: item.name, + avatar: provider.avatar, + providerId: provider.id, + providerName: t(provider.name as any), + typeLabel: item.typeLabel, + priceLabel: item.priceLabel, + order: provider.order, + tagColor: item.tagColor + }; + }); + formatList.sort((a, b) => a.order - b.order); + + const filterList = formatList.filter((item) => { + const providerFilter = provider ? item.providerId === provider : true; + + const regx = new RegExp(search, 'i'); + const nameFilter = search ? regx.test(item.name) : true; + + return providerFilter && nameFilter; + }); + + return filterList; + }, [ + provider, + modelType, + llmModelList, + vectorModelList, + audioSpeechModelList, + whisperModel, + t, + search + ]); + + return ( + + + + + {t('common:model.provider')} + + + + + + {t('common:model.model_type')} + + + + + + setSearch(e.target.value)} + placeholder={t('common:model.search_name_placeholder')} + /> + + + + + + + {t('common:model.name')} + {t('common:model.model_type')} + {t('common:model.billing')} + + + + {modelList.map((item) => ( + + + + + + {item.name} + + + + + {item.typeLabel} + + {item.priceLabel} + + ))} + + + + + ); +}; + +export default ModelTable; + +export const ModelPriceModal = ({ onClose }: { onClose: () => void }) => { + const { t } = useTranslation(); + + return ( + + + + + + ); +}; diff --git a/projects/app/src/components/support/wallet/StandardPlanContentList.tsx b/projects/app/src/components/support/wallet/StandardPlanContentList.tsx index 7caf82ddc..70b55d722 100644 --- a/projects/app/src/components/support/wallet/StandardPlanContentList.tsx +++ b/projects/app/src/components/support/wallet/StandardPlanContentList.tsx @@ -8,8 +8,8 @@ import { useTranslation } from 'next-i18next'; import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip'; import dynamic from 'next/dynamic'; -const AiPointsModal = dynamic(() => - import('@/pages/price/components/Points').then((mod) => mod.AiPointsModal) +const ModelPriceModal = dynamic(() => + import('@/components/core/ai/ModelTable').then((mod) => mod.ModelPriceModal) ); const StandardPlanContentList = ({ @@ -127,7 +127,7 @@ const StandardPlanContentList = ({ {t('common:support.wallet.subscription.web_site_sync')} )} - {isOpenAiPointsModal && } + {isOpenAiPointsModal && } ) : null; }; diff --git a/projects/app/src/global/common/api/systemRes.d.ts b/projects/app/src/global/common/api/systemRes.d.ts index 8ddf33697..f10c14d91 100644 --- a/projects/app/src/global/common/api/systemRes.d.ts +++ b/projects/app/src/global/common/api/systemRes.d.ts @@ -2,7 +2,7 @@ import type { LLMModelItemType, VectorModelItemType, AudioSpeechModels, - WhisperModelType, + STTModelType, ReRankModelItemType } from '@fastgpt/global/core/ai/model.d'; @@ -10,11 +10,12 @@ import type { FastGPTFeConfigsType } from '@fastgpt/global/common/system/types/i import { SubPlanType } from '@fastgpt/global/support/wallet/sub/type'; export type InitDateResponse = { + bufferId?: string; llmModels: LLMModelItemType[]; vectorModels: VectorModelItemType[]; audioSpeechModels: AudioSpeechModels[]; reRankModels: ReRankModelItemType[]; - whisperModel: WhisperModelType; + whisperModel: STTModelType; feConfigs: FastGPTFeConfigsType; subPlans?: SubPlanType; systemVersion: string; diff --git a/projects/app/src/pages/account/components/AccountContainer.tsx b/projects/app/src/pages/account/components/AccountContainer.tsx index 4515feeb2..5442b78c6 100644 --- a/projects/app/src/pages/account/components/AccountContainer.tsx +++ b/projects/app/src/pages/account/components/AccountContainer.tsx @@ -8,9 +8,7 @@ import PageContainer from '@/components/PageContainer'; import SideTabs from '@/components/SideTabs'; import LightRowTabs from '@fastgpt/web/components/common/Tabs/LightRowTabs'; import { useTranslation } from 'next-i18next'; -import Script from 'next/script'; import { useSystem } from '@fastgpt/web/hooks/useSystem'; -import { getWebReqUrl } from '@fastgpt/web/common/system/utils'; export enum TabEnum { 'info' = 'info', @@ -18,10 +16,11 @@ export enum TabEnum { 'usage' = 'usage', 'bill' = 'bill', 'inform' = 'inform', - 'individuation' = 'individuation', + 'setting' = 'setting', 'apikey' = 'apikey', 'loginout' = 'loginout', - 'team' = 'team' + 'team' = 'team', + 'model' = 'model' } const AccountContainer = ({ @@ -71,6 +70,11 @@ const AccountContainer = ({ } ] : []), + { + icon: 'common/model', + label: t('account:model_provider'), + value: TabEnum.model + }, ...(feConfigs?.show_promotion && userInfo?.team?.permission.isOwner ? [ { @@ -89,11 +93,7 @@ const AccountContainer = ({ } ] : []), - { - icon: 'support/user/individuation', - label: t('account:personalization'), - value: TabEnum.individuation - }, + ...(feConfigs.isPlus ? [ { @@ -103,6 +103,11 @@ const AccountContainer = ({ } ] : []), + { + icon: 'common/settingLight', + label: t('common:common.Setting'), + value: TabEnum.setting + }, { icon: 'support/account/loginoutLight', label: t('account:logout'), diff --git a/projects/app/src/pages/account/info/index.tsx b/projects/app/src/pages/account/info/index.tsx index 5bd2a9569..262ff95c4 100644 --- a/projects/app/src/pages/account/info/index.tsx +++ b/projects/app/src/pages/account/info/index.tsx @@ -48,15 +48,16 @@ import { serviceSideProps } from '@fastgpt/web/common/system/nextjs'; import { useRouter } from 'next/router'; import TeamSelector from '../components/TeamSelector'; -const StandDetailModal = dynamic(() => import('./components/standardDetailModal')); +const StandDetailModal = dynamic(() => import('./components/standardDetailModal'), { ssr: false }); const ConversionModal = dynamic(() => import('./components/ConversionModal')); const UpdatePswModal = dynamic(() => import('./components/UpdatePswModal')); const UpdateNotification = dynamic(() => import('./components/UpdateNotificationModal')); const OpenAIAccountModal = dynamic(() => import('./components/OpenAIAccountModal')); const LafAccountModal = dynamic(() => import('@/components/support/laf/LafAccountModal')); const CommunityModal = dynamic(() => import('@/components/CommunityModal')); -const AiPointsModal = dynamic(() => - import('@/pages/price/components/Points').then((mod) => mod.AiPointsModal) + +const ModelPriceModal = dynamic(() => + import('@/components/core/ai/ModelTable').then((mod) => mod.ModelPriceModal) ); const Info = () => { @@ -583,7 +584,7 @@ const PlanUsage = () => { {isOpenStandardModal && } - {isOpenAiPointsModal && } + {isOpenAiPointsModal && } ) : null; }; diff --git a/projects/app/src/pages/account/model/index.tsx b/projects/app/src/pages/account/model/index.tsx new file mode 100644 index 000000000..6af07f087 --- /dev/null +++ b/projects/app/src/pages/account/model/index.tsx @@ -0,0 +1,25 @@ +import { serviceSideProps } from '@fastgpt/web/common/system/nextjs'; +import React from 'react'; +import AccountContainer from '../components/AccountContainer'; +import { Box } from '@chakra-ui/react'; +import ModelTable from '@/components/core/ai/ModelTable'; + +const ModelProvider = () => { + return ( + + + + + + ); +}; + +export async function getServerSideProps(content: any) { + return { + props: { + ...(await serviceSideProps(content, ['account'])) + } + }; +} + +export default ModelProvider; diff --git a/projects/app/src/pages/account/individuation.tsx b/projects/app/src/pages/account/setting.tsx similarity index 82% rename from projects/app/src/pages/account/individuation.tsx rename to projects/app/src/pages/account/setting.tsx index d8eec2ac9..b276ada5a 100644 --- a/projects/app/src/pages/account/individuation.tsx +++ b/projects/app/src/pages/account/setting.tsx @@ -28,7 +28,7 @@ const Individuation = () => { }); reset(data); toast({ - title: t('account_individuation:update_data_success'), + title: t('account_setting:update_data_success'), status: 'success' }); }, @@ -39,19 +39,19 @@ const Individuation = () => { - - {t('account_individuation:personalization')} + + {t('common:common.Setting')} - {t('account_individuation:language')}: + {t('account_setting:language')}: - {t('account_individuation:timezone')}: + {t('account_setting:timezone')}: { @@ -69,7 +69,7 @@ const Individuation = () => { export async function getServerSideProps(content: any) { return { props: { - ...(await serviceSideProps(content, ['account', 'account_individuation'])) + ...(await serviceSideProps(content, ['account', 'account_setting'])) } }; } diff --git a/projects/app/src/pages/api/common/system/getInitData.ts b/projects/app/src/pages/api/common/system/getInitData.ts index 84a569fb4..33cdb4437 100644 --- a/projects/app/src/pages/api/common/system/getInitData.ts +++ b/projects/app/src/pages/api/common/system/getInitData.ts @@ -1,33 +1,38 @@ -import type { NextApiRequest, NextApiResponse } from 'next'; -import type { InitDateResponse } from '@/global/common/api/systemRes'; -import { connectToDatabase } from '@/service/mongo'; -import { jsonRes } from '@fastgpt/service/common/response'; +import type { NextApiResponse } from 'next'; +import { ApiRequestProps } from '@fastgpt/service/type/next'; +import { NextAPI } from '@/service/middleware/entry'; -async function handler(req: NextApiRequest, res: NextApiResponse) { - await connectToDatabase(); +async function handler(req: ApiRequestProps<{}, { bufferId?: string }>, res: NextApiResponse) { + const { bufferId } = req.query; - jsonRes(res, { - data: { - feConfigs: global.feConfigs, - subPlans: global.subPlans, - llmModels: global.llmModels.map((model) => ({ - ...model, - customCQPrompt: '', - customExtractPrompt: '', - defaultSystemChatPrompt: '' - })), - vectorModels: global.vectorModels, - reRankModels: - global.reRankModels?.map((item) => ({ - ...item, - requestUrl: '', - requestAuth: '' - })) || [], - whisperModel: global.whisperModel, - audioSpeechModels: global.audioSpeechModels, - systemVersion: global.systemVersion || '0.0.0' - } - }); + // If bufferId is the same as the current bufferId, return directly + if (bufferId && global.systemInitBufferId && global.systemInitBufferId === bufferId) { + return { + bufferId: global.systemInitBufferId + }; + } + + return { + bufferId: global.systemInitBufferId, + feConfigs: global.feConfigs, + subPlans: global.subPlans, + llmModels: global.llmModels.map((model) => ({ + ...model, + customCQPrompt: '', + customExtractPrompt: '', + defaultSystemChatPrompt: '' + })), + vectorModels: global.vectorModels, + reRankModels: + global.reRankModels?.map((item) => ({ + ...item, + requestUrl: '', + requestAuth: '' + })) || [], + whisperModel: global.whisperModel, + audioSpeechModels: global.audioSpeechModels, + systemVersion: global.systemVersion || '0.0.0' + }; } -export default handler; +export default NextAPI(handler); diff --git a/projects/app/src/pages/price/components/ExtraPlan.tsx b/projects/app/src/pages/price/components/ExtraPlan.tsx index 850564457..a83d6a59b 100644 --- a/projects/app/src/pages/price/components/ExtraPlan.tsx +++ b/projects/app/src/pages/price/components/ExtraPlan.tsx @@ -109,7 +109,7 @@ const ExtraPlan = () => { return ( { return ( { const { t } = useTranslation(); return ( { {t('common:support.wallet.subscription.Ai points')} - + {t('common:support.wallet.subscription.token_compute')} - + + + ); }; @@ -150,24 +152,3 @@ export const AiPointsTable = () => { ); }; - -export const AiPointsModal = ({ onClose }: { onClose: () => void }) => { - const { t } = useTranslation(); - - return ( - - - - - - ); -}; diff --git a/projects/app/src/service/common/system/index.ts b/projects/app/src/service/common/system/index.ts index b960d7ed7..1373e2440 100644 --- a/projects/app/src/service/common/system/index.ts +++ b/projects/app/src/service/common/system/index.ts @@ -52,8 +52,7 @@ export async function getInitConfig() { getSystemVersion(), // abandon - getSystemPlugin(), - getSystemPluginV1() + getSystemPlugin() ]); } @@ -79,7 +78,7 @@ const defaultFeConfigs: FastGPTFeConfigsType = { export async function initSystemConfig() { // load config - const [dbConfig, fileConfig] = await Promise.all([ + const [{ config: dbConfig, configId }, fileConfig] = await Promise.all([ getFastGPTConfigFromDB(), readConfigData('config.json') ]); @@ -106,7 +105,9 @@ export async function initSystemConfig() { }; // set config + global.systemInitBufferId = configId; initFastGPTConfig(config); + console.log({ feConfigs: global.feConfigs, systemEnv: global.systemEnv, @@ -162,32 +163,6 @@ function getSystemPlugin() { global.communityPlugins = fileTemplates; } -function getSystemPluginV1() { - if (global.communityPluginsV1 && global.communityPluginsV1.length > 0) return; - - const basePath = - process.env.NODE_ENV === 'development' - ? 'data/pluginTemplates/v1' - : '/app/data/pluginTemplates/v1'; - // read data/pluginTemplates directory, get all json file - const files = readdirSync(basePath); - // filter json file - const filterFiles = files.filter((item) => item.endsWith('.json')); - - // read json file - const fileTemplates: (PluginTemplateType & { weight: number })[] = filterFiles.map((filename) => { - const content = readFileSync(`${basePath}/${filename}`, 'utf-8'); - return { - ...JSON.parse(content), - id: `${PluginSourceEnum.community}-${filename.replace('.json', '')}`, - source: PluginSourceEnum.community - }; - }); - - fileTemplates.sort((a, b) => b.weight - a.weight); - - global.communityPluginsV1 = fileTemplates; -} export async function initSystemPlugins() { try { diff --git a/projects/app/src/types/index.d.ts b/projects/app/src/types/index.d.ts index f96bb1827..228ee1df8 100644 --- a/projects/app/src/types/index.d.ts +++ b/projects/app/src/types/index.d.ts @@ -5,7 +5,7 @@ import { LLMModelItemType, ReRankModelItemType, VectorModelItemType, - WhisperModelType + STTModelType } from '@fastgpt/global/core/ai/model.d'; import { TrackEventName } from '@/web/common/system/constants'; import { SubPlanType } from '@fastgpt/global/support/wallet/sub/type'; diff --git a/projects/app/src/web/common/system/api.ts b/projects/app/src/web/common/system/api.ts index 72122c185..c7e655829 100644 --- a/projects/app/src/web/common/system/api.ts +++ b/projects/app/src/web/common/system/api.ts @@ -1,4 +1,7 @@ import type { InitDateResponse } from '@/global/common/api/systemRes'; import { GET } from '@/web/common/api/request'; -export const getSystemInitData = () => GET('/common/system/getInitData'); +export const getSystemInitData = (bufferId?: string) => + GET('/common/system/getInitData', { + bufferId + }); diff --git a/projects/app/src/web/common/system/staticData.ts b/projects/app/src/web/common/system/staticData.ts index 6738a201f..e7131edca 100644 --- a/projects/app/src/web/common/system/staticData.ts +++ b/projects/app/src/web/common/system/staticData.ts @@ -10,7 +10,7 @@ export const clientInitData = async ( feConfigs: FastGPTFeConfigsType; }> => { try { - const res = await getSystemInitData(); + const res = await getSystemInitData(useSystemStore.getState().initDataBufferId); useSystemStore.getState().initStaticData(res); return { diff --git a/projects/app/src/web/common/system/useSystemStore.ts b/projects/app/src/web/common/system/useSystemStore.ts index de714b73e..a40122c90 100644 --- a/projects/app/src/web/common/system/useSystemStore.ts +++ b/projects/app/src/web/common/system/useSystemStore.ts @@ -8,11 +8,12 @@ import type { LLMModelItemType, ReRankModelItemType, VectorModelItemType, - WhisperModelType + STTModelType } from '@fastgpt/global/core/ai/model.d'; import { InitDateResponse } from '@/global/common/api/systemRes'; import { FastGPTFeConfigsType } from '@fastgpt/global/common/system/types'; import { SubPlanType } from '@fastgpt/global/support/wallet/sub/type'; +import { defaultWhisperModel } from '@fastgpt/global/core/ai/model'; type LoginStoreType = { provider: `${OAuthEnum}`; lastRoute: string; state: string }; @@ -35,6 +36,7 @@ type State = { isNotSufficientModal: boolean; setIsNotSufficientModal: (val: boolean) => void; + initDataBufferId?: string; feConfigs: FastGPTFeConfigsType; subPlans?: SubPlanType; systemVersion: string; @@ -43,7 +45,7 @@ type State = { vectorModelList: VectorModelItemType[]; audioSpeechModelList: AudioSpeechModelType[]; reRankModelList: ReRankModelItemType[]; - whisperModel?: WhisperModelType; + whisperModel: STTModelType; initStaticData: (e: InitDateResponse) => void; appType?: string; setAppType: (e?: string) => void; @@ -110,6 +112,7 @@ export const useSystemStore = create()( }); }, + initDataBufferId: undefined, feConfigs: {}, subPlans: undefined, systemVersion: '0.0.0', @@ -118,26 +121,38 @@ export const useSystemStore = create()( vectorModelList: [], audioSpeechModelList: [], reRankModelList: [], - whisperModel: undefined, + whisperModel: defaultWhisperModel, initStaticData(res) { set((state) => { - state.feConfigs = res.feConfigs || {}; - state.subPlans = res.subPlans; - state.systemVersion = res.systemVersion; + state.initDataBufferId = res.bufferId; + + state.feConfigs = res.feConfigs ?? state.feConfigs; + state.subPlans = res.subPlans ?? state.subPlans; + state.systemVersion = res.systemVersion ?? state.systemVersion; state.llmModelList = res.llmModels ?? state.llmModelList; state.datasetModelList = state.llmModelList.filter((item) => item.datasetProcess); state.vectorModelList = res.vectorModels ?? state.vectorModelList; state.audioSpeechModelList = res.audioSpeechModels ?? state.audioSpeechModelList; state.reRankModelList = res.reRankModels ?? state.reRankModelList; - state.whisperModel = res.whisperModel; + state.whisperModel = res.whisperModel ?? state.whisperModel; }); } })), { name: 'globalStore', partialize: (state) => ({ - loginStore: state.loginStore + loginStore: state.loginStore, + initDataBufferId: state.initDataBufferId, + feConfigs: state.feConfigs, + subPlans: state.subPlans, + systemVersion: state.systemVersion, + llmModelList: state.llmModelList, + datasetModelList: state.datasetModelList, + vectorModelList: state.vectorModelList, + audioSpeechModelList: state.audioSpeechModelList, + reRankModelList: state.reRankModelList, + whisperModel: state.whisperModel }) } ) diff --git a/projects/app/src/web/context/useInitApp.ts b/projects/app/src/web/context/useInitApp.ts index beb923572..a705e3645 100644 --- a/projects/app/src/web/context/useInitApp.ts +++ b/projects/app/src/web/context/useInitApp.ts @@ -5,6 +5,7 @@ import { useSystemStore } from '@/web/common/system/useSystemStore'; import type { FastGPTFeConfigsType } from '@fastgpt/global/common/system/types/index.d'; import { useMemoizedFn, useMount } from 'ahooks'; import { TrackEventName } from '../common/system/constants'; +import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; export const useInitApp = () => { const router = useRouter(); @@ -41,8 +42,6 @@ export const useInitApp = () => { }); useMount(() => { - initFetch(); - const errorTrack = (event: ErrorEvent) => { window.umami?.track(TrackEventName.windowError, { device: { @@ -62,6 +61,11 @@ export const useInitApp = () => { }; }); + useRequest2(initFetch, { + manual: false, + pollingInterval: 300000 + }); + useEffect(() => { hiId && localStorage.setItem('inviterId', hiId); bd_vid && sessionStorage.setItem('bd_vid', bd_vid);