diff --git a/document/content/docs/introduction/development/openapi/chat.mdx b/document/content/docs/introduction/development/openapi/chat.mdx index 4da75d00f..d5077bcf7 100644 --- a/document/content/docs/introduction/development/openapi/chat.mdx +++ b/document/content/docs/introduction/development/openapi/chat.mdx @@ -382,7 +382,7 @@ event取值: 对于用户选择,你只需要直接传递一个选择的结果给 messages 即可。 ```bash -curl --location --request POST 'https://api.fastgpt.in/api/v1/chat/completions' \ +curl --location --request POST 'https://localhost:3000/api/v1/chat/completions' \ --header 'Authorization: Bearer fastgpt-xxx' \ --header 'Content-Type: application/json' \ --data-raw '{ @@ -404,7 +404,7 @@ curl --location --request POST 'https://api.fastgpt.in/api/v1/chat/completions' 表单输入稍微麻烦一点,需要将输入的内容,以对象形式并序列化成字符串,作为`messages`的值。对象的 key 对应表单的 key,value 为用户输入的值。务必确保`chatId`是一致的。 ```bash -curl --location --request POST 'https://api.fastgpt.in/api/v1/chat/completions' \ +curl --location --request POST 'https://localhost:3000/api/v1/chat/completions' \ --header 'Authorization: Bearer fastgpt-xxxx' \ --header 'Content-Type: application/json' \ --data-raw '{ diff --git a/document/content/docs/introduction/development/openapi/dataset.mdx b/document/content/docs/introduction/development/openapi/dataset.mdx index 544e7a83c..46df17a35 100644 --- a/document/content/docs/introduction/development/openapi/dataset.mdx +++ b/document/content/docs/introduction/development/openapi/dataset.mdx @@ -935,7 +935,7 @@ curl --location --request DELETE 'http://localhost:3000/api/core/dataset/collect ```bash -curl --location --request POST 'https://api.fastgpt.in/api/core/dataset/data/pushData' \ +curl --location --request POST 'https://localhost:3000/api/core/dataset/data/pushData' \ --header 'Authorization: Bearer apikey' \ --header 'Content-Type: application/json' \ --data-raw '{ @@ -1238,7 +1238,7 @@ curl --location --request DELETE 'http://localhost:3000/api/core/dataset/data/de ```bash -curl --location --request POST 'https://api.fastgpt.in/api/core/dataset/searchTest' \ +curl --location --request POST 'https://localhost:3000/api/core/dataset/searchTest' \ --header 'Authorization: Bearer fastgpt-xxxxx' \ --header 'Content-Type: application/json' \ --data-raw '{ diff --git a/document/content/docs/introduction/development/openapi/intro.mdx b/document/content/docs/introduction/development/openapi/intro.mdx index 7f9ec84cd..bdf1cd89b 100644 --- a/document/content/docs/introduction/development/openapi/intro.mdx +++ b/document/content/docs/introduction/development/openapi/intro.mdx @@ -29,7 +29,7 @@ FastGPT 的 API Key **有 2 类**,一类是全局通用的 key (无法直接 OpenAPI 中,所有的接口都通过 Header.Authorization 进行鉴权。 ``` -baseUrl: "https://api.fastgpt.in/api" +baseUrl: "https://localhost:3000/api" headers: { Authorization: "Bearer {{apikey}}" } @@ -38,7 +38,7 @@ headers: { **发起应用对话示例** ```sh -curl --location --request POST 'https://api.fastgpt.in/api/v1/chat/completions' \ +curl --location --request POST 'https://localhost:3000/api/v1/chat/completions' \ --header 'Authorization: Bearer fastgpt-xxxxxx' \ --header 'Content-Type: application/json' \ --data-raw '{ @@ -59,7 +59,7 @@ curl --location --request POST 'https://api.fastgpt.in/api/v1/chat/completions' `v4.8.13`后支持传入自定义的用户 ID, 并且存入历史记录中。 ```sh -curl --location --request POST 'https://api.fastgpt.in/api/v1/chat/completions' \ +curl --location --request POST 'https://localhost:3000/api/v1/chat/completions' \ --header 'Authorization: Bearer fastgpt-xxxxxx' \ --header 'Content-Type: application/json' \ --data-raw '{ diff --git a/document/content/docs/upgrading/4-12/4121.mdx b/document/content/docs/upgrading/4-12/4121.mdx index deac0cee4..bc19c9d1c 100644 --- a/document/content/docs/upgrading/4-12/4121.mdx +++ b/document/content/docs/upgrading/4-12/4121.mdx @@ -15,5 +15,6 @@ description: 'FastGPT V4.12.1 更新说明' ## 🐛 修复 +1. 工具密钥输入,boolean 值无法通过 form 校验。 ## 🔨 工具更新 diff --git a/document/content/docs/use-cases/external-integration/openapi.mdx b/document/content/docs/use-cases/external-integration/openapi.mdx index 663d2e73e..9d210390b 100644 --- a/document/content/docs/use-cases/external-integration/openapi.mdx +++ b/document/content/docs/use-cases/external-integration/openapi.mdx @@ -24,7 +24,7 @@ import { Alert } from '@/components/docs/Alert'; ## 替换三方应用的变量 ```bash -OPENAI_API_BASE_URL: https://api.fastgpt.in/api (改成自己部署的域名) +OPENAI_API_BASE_URL: https://localhost:3000/api (改成自己部署的域名) OPENAI_API_KEY = 上一步获取到的密钥 ``` diff --git a/document/data/doc-last-modified.json b/document/data/doc-last-modified.json index 48505bf35..d4169a2be 100644 --- a/document/data/doc-last-modified.json +++ b/document/data/doc-last-modified.json @@ -30,9 +30,9 @@ "document/content/docs/introduction/development/modelConfig/one-api.mdx": "2025-07-23T21:35:03+08:00", "document/content/docs/introduction/development/modelConfig/ppio.mdx": "2025-08-05T23:20:39+08:00", "document/content/docs/introduction/development/modelConfig/siliconCloud.mdx": "2025-08-05T23:20:39+08:00", - "document/content/docs/introduction/development/openapi/chat.mdx": "2025-08-05T23:20:39+08:00", - "document/content/docs/introduction/development/openapi/dataset.mdx": "2025-08-13T16:31:28+08:00", - "document/content/docs/introduction/development/openapi/intro.mdx": "2025-07-23T21:35:03+08:00", + "document/content/docs/introduction/development/openapi/chat.mdx": "2025-08-14T16:11:54+08:00", + "document/content/docs/introduction/development/openapi/dataset.mdx": "2025-08-14T16:11:54+08:00", + "document/content/docs/introduction/development/openapi/intro.mdx": "2025-08-14T16:11:54+08:00", "document/content/docs/introduction/development/openapi/share.mdx": "2025-08-05T23:20:39+08:00", "document/content/docs/introduction/development/proxy/cloudflare.mdx": "2025-07-23T21:35:03+08:00", "document/content/docs/introduction/development/proxy/http_proxy.mdx": "2025-07-23T21:35:03+08:00", @@ -103,7 +103,7 @@ "document/content/docs/upgrading/4-11/4110.mdx": "2025-08-05T23:20:39+08:00", "document/content/docs/upgrading/4-11/4111.mdx": "2025-08-07T22:49:09+08:00", "document/content/docs/upgrading/4-12/4120.mdx": "2025-08-12T22:45:19+08:00", - "document/content/docs/upgrading/4-12/4121.mdx": "2025-08-13T21:31:30+08:00", + "document/content/docs/upgrading/4-12/4121.mdx": "2025-08-14T15:48:22+08:00", "document/content/docs/upgrading/4-8/40.mdx": "2025-08-02T19:38:37+08:00", "document/content/docs/upgrading/4-8/41.mdx": "2025-08-02T19:38:37+08:00", "document/content/docs/upgrading/4-8/42.mdx": "2025-08-02T19:38:37+08:00", @@ -182,6 +182,6 @@ "document/content/docs/use-cases/external-integration/dingtalk.mdx": "2025-07-23T21:35:03+08:00", "document/content/docs/use-cases/external-integration/feishu.mdx": "2025-07-24T14:23:04+08:00", "document/content/docs/use-cases/external-integration/official_account.mdx": "2025-08-05T23:20:39+08:00", - "document/content/docs/use-cases/external-integration/openapi.mdx": "2025-08-04T18:10:58+08:00", + "document/content/docs/use-cases/external-integration/openapi.mdx": "2025-08-14T16:11:54+08:00", "document/content/docs/use-cases/index.mdx": "2025-07-24T14:23:04+08:00" } \ No newline at end of file diff --git a/packages/service/core/chat/chatSchema.ts b/packages/service/core/chat/chatSchema.ts index 7819bd025..e22239fe3 100644 --- a/packages/service/core/chat/chatSchema.ts +++ b/packages/service/core/chat/chatSchema.ts @@ -89,7 +89,10 @@ const ChatSchema = new Schema({ }); try { - ChatSchema.index({ initCharts: 1 }); + // Tmp + ChatSchema.index({ initStatistics: 1 }); + ChatSchema.index({ appId: 1, tmbId: 1, outLinkUid: 1 }); + ChatSchema.index({ chatId: 1 }); // get user history ChatSchema.index({ tmbId: 1, appId: 1, top: -1, updateTime: -1 }); diff --git a/packages/web/i18n/zh-CN/chat.json b/packages/web/i18n/zh-CN/chat.json index 96de827ca..d21a51db7 100644 --- a/packages/web/i18n/zh-CN/chat.json +++ b/packages/web/i18n/zh-CN/chat.json @@ -40,7 +40,7 @@ "file_input": "系统文件", "file_input_tip": "可通过【插件开始】节点的“文件链接”获取对应文件的链接", "history_slider.home.title": "聊天", - "home.chat_app": "首页聊天-{{name}}", + "home.chat_app": "首页聊天", "home.no_available_tools": "暂无可用工具", "home.select_tools": "选择工具", "home.tools": "工具:{{num}}", diff --git a/packages/web/i18n/zh-Hant/chat.json b/packages/web/i18n/zh-Hant/chat.json index 31c36787e..2f2443e46 100644 --- a/packages/web/i18n/zh-Hant/chat.json +++ b/packages/web/i18n/zh-Hant/chat.json @@ -40,7 +40,7 @@ "file_input": "檔案輸入", "file_input_tip": "可透過「外掛程式啟動」節點的「檔案連結」取得對應檔案的連結", "history_slider.home.title": "聊天", - "home.chat_app": "首页聊天-{{name}}", + "home.chat_app": "首页聊天", "home.chat_id": "會話ID", "home.no_available_tools": "暫無可用工具", "home.select_tools": "選擇工具", diff --git a/projects/app/src/pageComponents/app/plugin/SecretInputModal.tsx b/projects/app/src/pageComponents/app/plugin/SecretInputModal.tsx index 5f69d986b..348a58c7e 100644 --- a/projects/app/src/pageComponents/app/plugin/SecretInputModal.tsx +++ b/projects/app/src/pageComponents/app/plugin/SecretInputModal.tsx @@ -25,6 +25,7 @@ import { secretInputTypeToInputType } from '@/components/core/app/formRender/uti import { getSystemPlugTemplates } from '@/web/core/app/api/plugin'; import type { NodeTemplateListItemType } from '@fastgpt/global/core/workflow/type/node'; import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; +import { InputTypeEnum } from '@/components/core/app/formRender/constant'; export type ToolParamsFormType = { type: SystemToolInputTypeEnum; @@ -262,18 +263,33 @@ const SecretInputModal = ({ ( - - )} + rules={{ + required: + item.required && + secretInputTypeToInputType(item.inputType) !== + InputTypeEnum.switch + ? true + : false, + validate: + item.required && + secretInputTypeToInputType(item.inputType) === + InputTypeEnum.switch + ? (value) => value !== undefined && value !== null + : undefined + }} + render={({ field: { onChange, value }, fieldState: { error } }) => { + return ( + + ); + }} /> )} diff --git a/projects/app/src/pageComponents/chat/ChatWindow/HomeChatWindow.tsx b/projects/app/src/pageComponents/chat/ChatWindow/HomeChatWindow.tsx index 756ac6508..e1aa78445 100644 --- a/projects/app/src/pageComponents/chat/ChatWindow/HomeChatWindow.tsx +++ b/projects/app/src/pageComponents/chat/ChatWindow/HomeChatWindow.tsx @@ -217,7 +217,7 @@ const HomeChatWindow = ({ myApps }: Props) => { variables, responseChatItemId, appId, - appName: t('chat:home.chat_app', { name: 'FastGPT' }), + appName: t('chat:home.chat_app'), chatId, ...form2AppWorkflow(formData, t) }, diff --git a/projects/app/src/pages/api/admin/initv4121.ts b/projects/app/src/pages/api/admin/initv4121.ts index 67582cb97..a993bb3b3 100644 --- a/projects/app/src/pages/api/admin/initv4121.ts +++ b/projects/app/src/pages/api/admin/initv4121.ts @@ -62,8 +62,8 @@ async function handler( } async function processChatRecord(chat: ChatSchemaType) { - async function calculateChatItemStats(chatId: string) { - const chatItems = await MongoChatItem.find({ chatId }).lean(); + async function calculateChatItemStats() { + const chatItems = await MongoChatItem.find({ appId: chat.appId, chatId: chat.chatId }).lean(); let chatItemCount = chatItems.length; let errorCount = 0; @@ -122,21 +122,21 @@ async function processChatRecord(chat: ChatSchemaType) { }; } - async function checkIsFirstChat(chat: any): Promise { + async function checkIsFirstChat(): Promise { const earliestChat = await MongoChat.findOne( { - userId: chat.userId, - appId: chat.appId + appId: chat.appId, + tmbId: chat.tmbId, + ...(chat.outLinkUid && { outLinkUid: chat.outLinkUid }) }, - {}, - { sort: { createTime: 1 } } + '_id' ).lean(); return earliestChat?._id.toString() === chat._id.toString(); } - const chatItemStats = await calculateChatItemStats(chat.chatId); - const isFirstChat = await checkIsFirstChat(chat); + const chatItemStats = await calculateChatItemStats(); + const isFirstChat = await checkIsFirstChat(); const chatLogData = { appId: chat.appId, diff --git a/projects/app/src/service/support/wallet/usage/push.ts b/projects/app/src/service/support/wallet/usage/push.ts index d8b2e5e16..d0b627443 100644 --- a/projects/app/src/service/support/wallet/usage/push.ts +++ b/projects/app/src/service/support/wallet/usage/push.ts @@ -152,12 +152,12 @@ export const pushQuestionGuideUsage = ({ createUsage({ teamId, tmbId, - appName: 'core.app.Question Guide', + appName: i18nT('common:core.app.Question Guide'), totalPoints, source: UsageSourceEnum.fastgpt, list: [ { - moduleName: 'core.app.Question Guide', + moduleName: i18nT('common:core.app.Question Guide'), amount: totalPoints, model: modelName, inputTokens, diff --git a/projects/app/src/web/core/chat/context/chatRecordContext.tsx b/projects/app/src/web/core/chat/context/chatRecordContext.tsx index 61e5ab429..1778899f1 100644 --- a/projects/app/src/web/core/chat/context/chatRecordContext.tsx +++ b/projects/app/src/web/core/chat/context/chatRecordContext.tsx @@ -77,8 +77,6 @@ const ChatRecordContextProvider = ({ scrollToBottom(); } - setIsChatRecordsLoaded(true); - return { ...res, list: res.list.map((item) => ({ @@ -93,7 +91,10 @@ const ChatRecordContextProvider = ({ refreshDeps: [params], params, scrollLoadType: 'top', - showErrorToast: false + showErrorToast: false, + onFinally() { + setIsChatRecordsLoaded(true); + } } );