From f7f4ffaee9889fbcd729658b15676fc460ac9243 Mon Sep 17 00:00:00 2001 From: duanshuwen Date: Mon, 20 Apr 2026 17:35:41 +0800 Subject: [PATCH] feat(api): add chat configuration and conversation message list APIs; update types and integrate into index --- docs/todo-list.md | 2 +- src/api/chatConfig.ts | 17 ++++ src/api/conversationMessageList.ts | 26 +++++ src/api/index.ts | 5 + src/api/modelConfig.ts | 17 ++++ src/api/recentConversation.ts | 17 ++++ src/api/recommendedQuestionList.ts | 17 ++++ src/api/types.ts | 116 +++++++++++++++++++++++ src/components/chat/ChatHistoryPanel.tsx | 8 -- 9 files changed, 216 insertions(+), 9 deletions(-) create mode 100644 src/api/chatConfig.ts create mode 100644 src/api/conversationMessageList.ts create mode 100644 src/api/modelConfig.ts create mode 100644 src/api/recentConversation.ts create mode 100644 src/api/recommendedQuestionList.ts diff --git a/docs/todo-list.md b/docs/todo-list.md index a8e198e..02d3393 100644 --- a/docs/todo-list.md +++ b/docs/todo-list.md @@ -3,7 +3,7 @@ 1、任务列表 - 完成 2、走本地模型配置,重构模型对话功能 - 完成 3、一键打开渠道可以新增渠道 - 完成 -4、把龙虾包装到对话 +4、把龙虾包装到对话 - 完成 5、迁移频道功能 - 完成 6、迁移agent功能 - 完成 7、知识库调整成上传文件,查看文件列表 - 完成 \ No newline at end of file diff --git a/src/api/chatConfig.ts b/src/api/chatConfig.ts new file mode 100644 index 0000000..af3c623 --- /dev/null +++ b/src/api/chatConfig.ts @@ -0,0 +1,17 @@ +/* eslint-disable */ +// @ts-ignore +import request from './request'; + +import * as API from './types'; + +/** 获取聊天配置 获取聊天配置 POST /chat/chatConfig */ +export function chatChatConfigUsingPost({ + options, +}: { + options?: { [key: string]: unknown }; +}) { + return request('/chat/chatConfig', { + method: 'POST', + ...(options || {}), + }); +} diff --git a/src/api/conversationMessageList.ts b/src/api/conversationMessageList.ts new file mode 100644 index 0000000..8716acf --- /dev/null +++ b/src/api/conversationMessageList.ts @@ -0,0 +1,26 @@ +/* eslint-disable */ +// @ts-ignore +import request from './request'; + +import * as API from './types'; + +/** 对话的消息列表 对话的消息列表 POST /chat/conversationMessageList */ +export function chatConversationMessageListUsingPost({ + body, + options, +}: { + body: API.ConversationMessageListSearchForm; + options?: { [key: string]: unknown }; +}) { + return request( + '/chat/conversationMessageList', + { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + } + ); +} diff --git a/src/api/index.ts b/src/api/index.ts index 9cd4dd7..64faf9e 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -12,3 +12,8 @@ export * from './commodityOrderList'; export * from './userOrderDetail'; export * from './createEvent'; export * from './eventList'; +export * from './recentConversation'; +export * from './conversationMessageList'; +export * from './recommendedQuestionList'; +export * from './chatConfig'; +export * from './modelConfig'; diff --git a/src/api/modelConfig.ts b/src/api/modelConfig.ts new file mode 100644 index 0000000..578957b --- /dev/null +++ b/src/api/modelConfig.ts @@ -0,0 +1,17 @@ +/* eslint-disable */ +// @ts-ignore +import request from './request'; + +import * as API from './types'; + +/** 获取模型配置 获取模型配置 GET /chat/modelConfig */ +export function chatModelConfigUsingGet({ + options, +}: { + options?: { [key: string]: unknown }; +}) { + return request('/chat/modelConfig', { + method: 'GET', + ...(options || {}), + }); +} diff --git a/src/api/recentConversation.ts b/src/api/recentConversation.ts new file mode 100644 index 0000000..780fd64 --- /dev/null +++ b/src/api/recentConversation.ts @@ -0,0 +1,17 @@ +/* eslint-disable */ +// @ts-ignore +import request from './request'; + +import * as API from './types'; + +/** 获取最近的一次对话 获取最近的一次对话 GET /chat/recentConversation */ +export function chatRecentConversationUsingGet({ + options, +}: { + options?: { [key: string]: unknown }; +}) { + return request('/chat/recentConversation', { + method: 'GET', + ...(options || {}), + }); +} diff --git a/src/api/recommendedQuestionList.ts b/src/api/recommendedQuestionList.ts new file mode 100644 index 0000000..fd88f54 --- /dev/null +++ b/src/api/recommendedQuestionList.ts @@ -0,0 +1,17 @@ +/* eslint-disable */ +// @ts-ignore +import request from './request'; + +import * as API from './types'; + +/** 推荐问题列表(换一批) 推荐问题列表(换一批) GET /chat/recommendedQuestionList */ +export function chatRecommendedQuestionListUsingGet({ + options, +}: { + options?: { [key: string]: unknown }; +}) { + return request('/chat/recommendedQuestionList', { + method: 'GET', + ...(options || {}), + }); +} diff --git a/src/api/types.ts b/src/api/types.ts index e6627b7..bb37897 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -24,6 +24,35 @@ export type AuthOauth2TokenUsingPostResponses = { 200: AuthOauth2TokenUsingPostResponse; }; +export type ChatChatConfigUsingPostResponses = { + 200: RChatConfigDTO; +}; + +export type ChatConfigDTO = { + /** 智能体id */ + agentId?: string; + /** 引导词列表 */ + guideWords?: string[]; + /** 欢迎语 */ + welcomeContent?: string; +}; + +export type ChatConversationMessageListUsingPostResponses = { + 200: RPageConversationMessageDTO; +}; + +export type ChatModelConfigUsingGetResponses = { + 200: RModelConfigDTO; +}; + +export type ChatRecentConversationUsingGetResponses = { + 200: RConversationDTO; +}; + +export type ChatRecommendedQuestionListUsingGetResponses = { + 200: RListString; +}; + export type CommodityEquipmentDTO = { /** 设施图标 */ icon?: string; @@ -177,6 +206,39 @@ export type ConsumerInfoEntity = { contactPhone?: string; }; +export type ConversationDTO = { + /** 会话id */ + conversationId?: string; +}; + +export type ConversationMessageDTO = { + /** 消息id */ + messageId?: string; + /** 消息所属的会话id */ + conversationId?: string; + /** 消息类型 0-文本 1-图片 2-音频 3-视频 4-文件 5-命令 */ + messageType?: string; + /** 消息内容 */ + messageContent?: string; + /** 消息渲染 */ + messageDisplay?: string; + /** 消息发送者id */ + messageSenderId?: string; + /** 消息发送者角色 */ + messageSenderRole?: string; + /** 消息时间 */ + messageTime?: string; +}; + +export type ConversationMessageListSearchForm = { + /** 页码 */ + pageNum: number; + /** 页面数量 */ + pageSize: number; + /** 对话id */ + conversationId?: string; +}; + export type CreateEventForm = { /** 实体名称 */ entityName?: string; @@ -264,6 +326,17 @@ export type HotelStaffTypeMappingUpdateUsingPostResponses = { 200: RBoolean; }; +export type ModelConfigDTO = { + /** 供应商名称 */ + providerName?: string; + /** 模型apiKey */ + apiKey?: string; + /** 模型请求地址 */ + baseUrl?: string; + /** 模型名称 */ + model?: string; +}; + export type OpenDateRangeDTO = { /** 起始时间 */ begin?: string; @@ -301,6 +374,19 @@ export type PageCommodityOrderDTO = { countId?: string; }; +export type PageConversationMessageDTO = { + records?: ConversationMessageDTO[]; + total?: number; + size?: number; + current?: number; + orders?: OrderItem[]; + optimizeCountSql?: boolean; + searchCount?: boolean; + optimizeJoinOfCountSql?: boolean; + maxLimit?: number; + countId?: string; +}; + export type PageEventDataDTO = { records?: EventDataDTO[]; total?: number; @@ -403,6 +489,18 @@ export type RBoolean = { data?: boolean; }; +export type RChatConfigDTO = { + code?: number; + msg?: string; + data?: ChatConfigDTO; +}; + +export type RConversationDTO = { + code?: number; + msg?: string; + data?: ConversationDTO; +}; + export type RListPcConfigChannel = { code?: number; msg?: string; @@ -415,6 +513,18 @@ export type RListRoomTypeMapping = { data?: RoomTypeMapping[]; }; +export type RListString = { + code?: number; + msg?: string; + data?: string[]; +}; + +export type RModelConfigDTO = { + code?: number; + msg?: string; + data?: ModelConfigDTO; +}; + export type RoomTypeMapping = { /** * 创建者 @@ -460,6 +570,12 @@ export type RPageCommodityOrderDTO = { data?: PageCommodityOrderDTO; }; +export type RPageConversationMessageDTO = { + code?: number; + msg?: string; + data?: PageConversationMessageDTO; +}; + export type RPageEventDataDTO = { code?: number; msg?: string; diff --git a/src/components/chat/ChatHistoryPanel.tsx b/src/components/chat/ChatHistoryPanel.tsx index 3e9cc87..c767521 100644 --- a/src/components/chat/ChatHistoryPanel.tsx +++ b/src/components/chat/ChatHistoryPanel.tsx @@ -45,8 +45,6 @@ function ChatHistoryPanel({ const [menuState, setMenuState] = useState(null); const [isCompact, setIsCompact] = useState(false); - const hasSessions = buckets.some((bucket) => bucket.sessions.length > 0); - useEffect(() => { setCollapsedBuckets((current) => { const next: Record = {}; @@ -164,12 +162,6 @@ function ChatHistoryPanel({ ) : null} - {!loading && !hasSessions ? ( -
- 还没有对话,点击“新对话”开始。 -
- ) : null} - {!isCompact ? buckets.map((bucket) => { const isCollapsed = collapsedBuckets[bucket.key] ?? false;