diff --git a/client/public/docs/chatProblem.md b/client/public/docs/chatProblem.md index a779d4561..0dcc43d28 100644 --- a/client/public/docs/chatProblem.md +++ b/client/public/docs/chatProblem.md @@ -1,10 +1,11 @@ ### 常见问题 -- [**Git 地址**,点击查看项目地址](https://github.com/labring/FastGPT) +- [**Git 地址**,点击查看项目地址](https://github.com/labring/FastGPT) - [本地部署 FastGPT](https://doc.fastgpt.run/docs/installation) - [API 文档](https://kjqvjse66l.feishu.cn/docx/DmLedTWtUoNGX8xui9ocdUEjnNh?pre_pathname=%2Fdrive%2Fhome%2F) - **反馈问卷**: 如果你遇到任何使用问题或有期望的功能,可以[填写该问卷](https://www.wjx.cn/vm/rLIw1uD.aspx#) - **问题文档**: [先看文档,再提问](https://kjqvjse66l.feishu.cn/docx/HtrgdT0pkonP4kxGx8qcu6XDnGh) +- [点击查看商业版文档](https://fael3z0zfze.feishu.cn/docx/F155dbirfo8vDDx2WgWc6extnwf) **价格表** | 计费项 | 价格: 元/ 1K tokens(包含上下文)| diff --git a/client/public/docs/versionIntro.md b/client/public/docs/versionIntro.md index 06c1c19b0..f3f0650ad 100644 --- a/client/public/docs/versionIntro.md +++ b/client/public/docs/versionIntro.md @@ -1,8 +1,7 @@ -### Fast GPT V4.2 +### Fast GPT V4.2.2 -1. 新增 - 应用日志初版,可观测到所有对话记录 -2. 新增 - 好友邀请链接,[点击查看](/account?currentTab=promotion) -3. 新增 - Iframe 嵌入页面图标可拖拽 -4. 优化 - 知识库搜索提示词 -5. 优化 - [使用文档](https://doc.fastgpt.run/docs/intro/) -6. [点击查看高级编排介绍文档](https://doc.fastgpt.run/docs/workflow) +1. **新增 - 用户反馈和管理员标注预期答案,以不断提高模型回复准确率。** 该功能为测试版,未来交互可能会有变化,欢迎大家提出宝贵意见。 +2. 优化 - 知识库搜索提示词,更适配问答场景。 +3. 新增 - 好友邀请链接,[点击查看](/account?currentTab=promotion) +4. 优化 - [使用文档](https://doc.fastgpt.run/docs/intro/) +5. [点击查看高级编排介绍文档](https://doc.fastgpt.run/docs/workflow) diff --git a/client/public/locales/en/common.json b/client/public/locales/en/common.json index 510761c2a..4accb501d 100644 --- a/client/public/locales/en/common.json +++ b/client/public/locales/en/common.json @@ -3,6 +3,7 @@ "Cancel": "No", "Confirm": "Yes", "Running": "Running", + "Select value is empty": "Select value is empty", "UnKnow": "UnKnow", "Warning": "Warning", "app": { @@ -17,6 +18,7 @@ "Copy Module Config": "Copy config", "Export Config Successful": "The configuration has been copied. Please check for important data", "Export Configs": "Export Configs", + "Feedback Count": "User Feedback", "Import Config": "Import Config", "Import Config Failed": "Failed to import the configuration, please ensure that the configuration is normal!", "Import Configs": "Import Configs", @@ -26,16 +28,33 @@ "Logs Source": "Source", "Logs Time": "Time", "Logs Title": "Title", + "Mark Count": "Mark Count", "My Apps": "My Apps", "Output Field Settings": "Output Field Settings", "Paste Config": "Paste Config" }, "chat": { + "Admin Mark Content": "Corrected response", "Complete Response": "Complete Response", "Confirm to clear history": "Confirm to clear history?", "Exit Chat": "Exit", + "Feedback Failed": "Feedback Failed", + "Feedback Mark": "Mark", + "Feedback Modal": "Feedback", + "Feedback Modal Tip": "Enter what you find unsatisfactory", + "Feedback Close": "Close Feedback", + "Feedback Submit": "Submit", + "Feedback Success": "Feedback Success", + "Feedback Update Failed": "Feedback Update Failed", "History": "History", + "Mark": "Mark", + "Mark Description": "The annotation feature is currently in beta. \n\n After clicking Add annotation, you need to select a knowledge base in order to store annotation data. You can use this feature to quickly annotate questions and expected answers to guide the model to the next answer. At present, the annotation function, like other data in the knowledge base, is affected by the model, which does not mean that the annotation meets 100% expectations. The \n\n annotation data is only unidirectional synchronization with the knowledge base. If the knowledge base modifies the annotation data, the annotation data displayed in the log cannot be synchronized", + "Mark Description Title": "Mark Description", "New Chat": "New Chat", + "Read Mark Description": "Read mark description", + "Read User Feedback": "Read user feedback", + "Select Mark Kb": "Select Dataset", + "Select Mark Kb Desc": "Select a dataset to store the expected answers", "You need to a chat app": "You need to a chat app", "logs": { "api": "API", diff --git a/client/public/locales/zh/common.json b/client/public/locales/zh/common.json index d43da7a66..6022e06f6 100644 --- a/client/public/locales/zh/common.json +++ b/client/public/locales/zh/common.json @@ -3,8 +3,9 @@ "Cancel": "取消", "Confirm": "确认", "Running": "运行中", - "Warning": "提示", + "Select value is empty": "选择的内容为空", "UnKnow": "未知", + "Warning": "提示", "app": { "Advance App TestTip": "当前应用为高级编排模式\n如需切换为【简易模式】请点击左侧保存按键", "App Detail": "应用详情", @@ -17,6 +18,7 @@ "Copy Module Config": "复制配置", "Export Config Successful": "已复制配置,请注意检查是否有重要数据", "Export Configs": "导出配置", + "Feedback Count": "用户反馈", "Import Config": "导入配置", "Import Config Failed": "导入配置失败,请确保配置正常!", "Import Configs": "导入配置", @@ -26,16 +28,33 @@ "Logs Source": "来源", "Logs Time": "时间", "Logs Title": "标题", + "Mark Count": "标注答案数量", "My Apps": "我的应用", "Output Field Settings": "输出字段编辑", "Paste Config": "粘贴配置" }, "chat": { + "Admin Mark Content": "纠正后的回复", "Complete Response": "完整响应", "Confirm to clear history": "确认清空该应用的聊天记录?", "Exit Chat": "退出聊天", + "Feedback Failed": "提交反馈异常", + "Feedback Mark": "标注", + "Feedback Modal": "结果反馈", + "Feedback Modal Tip": "输入你觉得回答不满意的地方", + "Feedback Close": "关闭反馈", + "Feedback Submit": "提交反馈", + "Feedback Success": "反馈成功!", + "Feedback Update Failed": "更新反馈状态失败", "History": "记录", + "Mark": "标注预期回答", + "Mark Description": "当前标注功能为测试版。\n\n点击添加标注后,需要选择一个知识库,以便存储标注数据。你可以通过该功能快速的标注问题和预期回答,以便引导模型下次的回答。\n\n目前,标注功能同知识库其他数据一样,受模型的影响,不代表标注后 100% 符合预期。\n\n标注数据仅单向与知识库同步,如果知识库修改了该标注数据,日志展示的标注数据无法同步", + "Mark Description Title": "标注功能介绍", "New Chat": "新对话", + "Read Mark Description": "查看标注功能介绍", + "Read User Feedback": "查看用户反馈", + "Select Mark Kb": "选择知识库", + "Select Mark Kb Desc": "选择一个知识库存储预期答案", "You need to a chat app": "你需要创建一个应用", "logs": { "api": "API 调用", diff --git a/client/src/api/chat.ts b/client/src/api/chat.ts index 8406b56f6..c7fa4447b 100644 --- a/client/src/api/chat.ts +++ b/client/src/api/chat.ts @@ -5,6 +5,7 @@ import { RequestPaging } from '../types/index'; import type { OutLinkSchema } from '@/types/mongoSchema'; import type { ShareChatEditType } from '@/types/app'; import type { Props as UpdateHistoryProps } from '@/pages/api/chat/history/updateChatHistory'; +import { AdminUpdateFeedbackParams } from './request/chat'; /** * 获取初始化聊天内容 @@ -64,3 +65,9 @@ export const getShareChatList = (appId: string) => * delete a shareChat */ export const delShareChatById = (id: string) => DELETE(`/chat/shareChat/delete?id=${id}`); + +export const userUpdateChatFeedback = (data: { chatItemId: string; userFeedback?: string }) => + POST('/chat/feedback/userUpdate', data); + +export const adminUpdateChatFeedback = (data: AdminUpdateFeedbackParams) => + POST('/chat/feedback/adminUpdate', data); diff --git a/client/src/api/plugins/kb.ts b/client/src/api/plugins/kb.ts index 9ef075426..a705c7c58 100644 --- a/client/src/api/plugins/kb.ts +++ b/client/src/api/plugins/kb.ts @@ -66,6 +66,14 @@ export const getKbDataItemById = (dataId: string) => export const postKbDataFromList = (data: PushDataProps) => POST(`/openapi/kb/pushData`, data); +/** + * insert one data to dataset + */ +export const insertData2Kb = (data: { + kbId: string; + data: { a: string; q: string; source?: string }; +}) => POST(`/plugins/kb/data/insertData`, data); + /** * 更新一条数据 */ diff --git a/client/src/api/request/chat.d.ts b/client/src/api/request/chat.d.ts new file mode 100644 index 000000000..19299f0bd --- /dev/null +++ b/client/src/api/request/chat.d.ts @@ -0,0 +1,6 @@ +export type AdminUpdateFeedbackParams = { + chatItemId: string; + kbId: string; + dataId: string; + content: string; +}; diff --git a/client/src/components/ChatBox/FeedbackModal.tsx b/client/src/components/ChatBox/FeedbackModal.tsx new file mode 100644 index 000000000..7d622f97e --- /dev/null +++ b/client/src/components/ChatBox/FeedbackModal.tsx @@ -0,0 +1,56 @@ +import React, { useRef } from 'react'; +import { ModalBody, Textarea, ModalFooter, Button } from '@chakra-ui/react'; +import MyModal from '../MyModal'; +import { useRequest } from '@/hooks/useRequest'; +import { useTranslation } from 'next-i18next'; +import { userUpdateChatFeedback } from '@/api/chat'; + +const FeedbackModal = ({ + chatItemId, + onSuccess, + onClose +}: { + chatItemId: string; + onSuccess: (e: string) => void; + onClose: () => void; +}) => { + const ref = useRef(null); + const { t } = useTranslation(); + + const { mutate, isLoading } = useRequest({ + mutationFn: async () => { + const val = ref.current?.value || 'N/A'; + return userUpdateChatFeedback({ + chatItemId, + userFeedback: val + }); + }, + onSuccess() { + onSuccess(ref.current?.value || 'N/A'); + }, + successToast: t('chat.Feedback Success'), + errorToast: t('chat.Feedback Failed') + }); + + return ( + + +