diff --git a/ui/src/api/API_README.md b/ui/src/api/API_README.md index 5163307e850..9402f75c918 100644 --- a/ui/src/api/API_README.md +++ b/ui/src/api/API_README.md @@ -806,3 +806,12 @@ Workspace 和 System 资源管理的 `getKnowledgeDetail(knowledgeId, section?)` `abstract` 和按时间正序排列的 `chat_record_list`。当前后端返回旧版 `problem_text`、 `answer_text`、`answer_text_list` 及仅含上传附件的 `execution_details`,不返回 V3 `question`、`messages`。 分享页适配旧版字段,不通过原会话接口补查内容。 + +### 对话回答反馈 + +`chat/conversation.ts` 的 `putConversationFeedback(applicationId, chatId, recordId, data)` 使用 +PUT `/v3/application//chat//chat_record//vote`。 +提交类型 `ChatFeedback` 经 `@/api/types` 导出;`vote_status` 为 `-1`(撤销)、`0`(满意)、 +`1`(不满意)字符串,`vote_reason` 为单选原因,`vote_other_content` 为补充说明。 +满意原因支持 `accurate`、`complete`、`other`,不满意支持 `inaccurate`、`incomplete`、`other`。 +已评价记录须先撤销才能再次评价;历史记录通过同名字段回显。 diff --git a/ui/src/api/chat/conversation.ts b/ui/src/api/chat/conversation.ts index 504e8c52897..f2ef194b1e0 100644 --- a/ui/src/api/chat/conversation.ts +++ b/ui/src/api/chat/conversation.ts @@ -1,7 +1,7 @@ import { get, post, put, del, postStream } from './core/request' import type { ResponsePage } from './core/types' import { CHAT_API_BASE_PATH as chatApiBase } from '@/api/constants' -import type { ChatLogRecord, ChatShareDetail, PortalConversationSummary } from '@/api/types' +import type { ChatFeedback, ChatLogRecord, ChatShareDetail, PortalConversationSummary } from '@/api/types' /** v3 对话接口均按智能体划分资源路径。 */ const getApplicationPath = (applicationId: string) => `/v3/application/${applicationId}` @@ -46,6 +46,10 @@ const putConversation = (applicationId: string, chatId: string, data: unknown) = const postShareConversation = (applicationId: string, chatId: string, data: { chat_record_ids: string[] }) => post<{ chat_record_ids: string[] }, { link: string }>(`${getApplicationPath(applicationId)}/chat/${chatId}/share_chat`, data) +/** 保存或撤销当前回答的反馈。 */ +const putConversationFeedback = (applicationId: string, chatId: string, recordId: string, data: ChatFeedback) => + put(`${getApplicationPath(applicationId)}/chat/${chatId}/chat_record/${recordId}/vote`, data) + /** 获取公开分享的对话记录,无需智能体访问凭证。 */ const getShareConversation = (shareId: string) => get(`/share/${encodeURIComponent(shareId)}`) @@ -53,6 +57,7 @@ const getShareConversation = (shareId: string) => get(`/share/$ const postSpeechToText = (applicationId: string, data: unknown) => post(`${getApplicationPath(applicationId)}/speech_to_text`, data) export default { + putConversationFeedback, getConversationOpen, postConversationMessage, postCancelConversationMessage, diff --git a/ui/src/api/types/chat-log.ts b/ui/src/api/types/chat-log.ts index 67203b162ff..5a0053097f9 100644 --- a/ui/src/api/types/chat-log.ts +++ b/ui/src/api/types/chat-log.ts @@ -45,7 +45,7 @@ export interface ChatContent { } /** 对话日志中的单条问答记录,仅列出前端使用的字段。 */ -export interface ChatLogRecord { +export interface ChatLogRecord extends Partial { id: string create_time?: string /** 提问内容项 */ @@ -58,3 +58,10 @@ export interface ChatLogRecord { paragraph_list?: Dict[] execution_details?: Dict[] } + +/** 对话反馈:-1 未评价,0 满意,1 不满意。 */ +export interface ChatFeedback { + vote_status: '-1' | '0' | '1' + vote_reason?: 'accurate' | 'complete' | 'inaccurate' | 'incomplete' | 'other' | null + vote_other_content?: string +} diff --git a/ui/src/conversation-panel/components/log-message-footer/index.vue b/ui/src/conversation-panel/components/log-message-footer/index.vue new file mode 100644 index 00000000000..b95d1b921e0 --- /dev/null +++ b/ui/src/conversation-panel/components/log-message-footer/index.vue @@ -0,0 +1,74 @@ + + + + + diff --git a/ui/src/conversation-panel/components/log-message-list/index.vue b/ui/src/conversation-panel/components/log-message-list/index.vue index 23a65fabaf7..51790f0af33 100644 --- a/ui/src/conversation-panel/components/log-message-list/index.vue +++ b/ui/src/conversation-panel/components/log-message-list/index.vue @@ -1,7 +1,7 @@ + + + + diff --git a/ui/src/conversation-panel/components/message-footer/index.vue b/ui/src/conversation-panel/components/message-footer/index.vue index b95d1b921e0..06cb185ef0f 100644 --- a/ui/src/conversation-panel/components/message-footer/index.vue +++ b/ui/src/conversation-panel/components/message-footer/index.vue @@ -1,5 +1,6 @@