From d8d9b936c4f36d4418f41e129360aa2d5503c5e5 Mon Sep 17 00:00:00 2001 From: Archer <545436317@qq.com> Date: Mon, 18 Nov 2024 10:27:52 +0800 Subject: [PATCH] fix: custom uid (#3177) * chat api doc * fix: custom uid --- docSite/content/zh-cn/docs/development/openapi/chat.md | 4 +++- projects/app/src/pages/chat/share.tsx | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docSite/content/zh-cn/docs/development/openapi/chat.md b/docSite/content/zh-cn/docs/development/openapi/chat.md index 7f03bb6e6..3af0542cd 100644 --- a/docSite/content/zh-cn/docs/development/openapi/chat.md +++ b/docSite/content/zh-cn/docs/development/openapi/chat.md @@ -35,9 +35,10 @@ curl --location --request POST 'http://localhost:3000/api/v1/chat/completions' \ --header 'Authorization: Bearer fastgpt-xxxxxx' \ --header 'Content-Type: application/json' \ --data-raw '{ - "chatId": "abcd", + "chatId": "my_chatId", "stream": false, "detail": false, + "responseChatItemId": "my_responseChatItemId", "variables": { "uid": "asdfadsfasfd2323", "name": "张三" @@ -104,6 +105,7 @@ curl --location --request POST 'http://localhost:3000/api/v1/chat/completions' \ - 为 `undefined` 时(不传入),不使用 FastGpt 提供的上下文功能,完全通过传入的 messages 构建上下文。 不会将你的记录存储到数据库中,你也无法在记录汇总中查阅到。 - 为`非空字符串`时,意味着使用 chatId 进行对话,自动从 FastGpt 数据库取历史记录,并使用 messages 数组最后一个内容作为用户问题。请自行确保 chatId 唯一,长度小于250,通常可以是自己系统的对话框ID。 - messages: 结构与 [GPT接口](https://platform.openai.com/docs/api-reference/chat/object) chat模式一致。 +- responseChatItemId: string | undefined 。如果传入,则会将该值作为本次对话的响应消息的 ID,FastGPT 会自动将该 ID 存入数据库。请确保,在当前`chatId`下,`responseChatItemId`是唯一的。 - detail: 是否返回中间值(模块状态,响应的完整结果等),`stream模式`下会通过`event`进行区分,`非stream模式`结果保存在`responseData`中。 - variables: 模块变量,一个对象,会替换模块中,输入框内容里的`{{key}}` {{% /alert %}} diff --git a/projects/app/src/pages/chat/share.tsx b/projects/app/src/pages/chat/share.tsx index 76b298422..a4f066dd9 100644 --- a/projects/app/src/pages/chat/share.tsx +++ b/projects/app/src/pages/chat/share.tsx @@ -385,7 +385,7 @@ const Render = (props: Props) => { const [isLoaded, setIsLoaded] = useState(false); const contextParams = useMemo(() => { - return { shareId, outLinkUid: authToken || localUId || customUid }; + return { shareId, outLinkUid: authToken || customUid || localUId }; }, [authToken, customUid, localUId, shareId]); useMount(() => {