From c3f1433868788a7480755f16f475486394024670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E7=BA=A7=E8=80=81=E7=99=BD=E5=85=94?= Date: Wed, 22 Oct 2025 16:36:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EAI=E5=AF=B9=E8=AF=9D=E5=92=8C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86=E6=8E=A5=E5=8F=A3=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B6=88=E6=81=AF=E5=8F=91=E9=80=81=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BB=A5=E6=94=AF=E6=8C=81=E7=BE=A4=E7=BB=84=E5=92=8C?= =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E6=B6=88=E6=81=AF=E7=9A=84=E5=A4=84=E7=90=86?= =?UTF-8?q?=EF=BC=8C=E6=8F=90=E5=8D=87=E8=81=8A=E5=A4=A9=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E7=9A=84=E7=81=B5=E6=B4=BB=E6=80=A7=E5=92=8C=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BD=93=E9=AA=8C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Touchkebao/src/api/ai.ts | 39 +++++++++++++++++++- Touchkebao/src/store/module/weChat/weChat.ts | 22 ++++++++++- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/Touchkebao/src/api/ai.ts b/Touchkebao/src/api/ai.ts index 35625ecb..6dca8751 100644 --- a/Touchkebao/src/api/ai.ts +++ b/Touchkebao/src/api/ai.ts @@ -1,5 +1,42 @@ import axios from "axios"; import { useUserStore } from "@/store/module/user"; +import { request } from "@/api/request"; + +//ai对话接口 +export interface AiChatParams { + friendId: number; + wechatAccountId: number; + [property: string]: any; +} + +export function aiChat(params: AiChatParams) { + return request("/v1/kefu/ai/chat", params, "POST"); +} + +//soket消息传入数据中心 +export interface DataProcessingParams { + /** + * 群消息 + */ + chatroomMessage?: string[]; + /** + * 个人信息 + */ + friendMessage?: string[]; + /** + * 类型固定值 + */ + type?: string; + /** + * 公共 + */ + wechatAccountId?: string; + [property: string]: any; +} + +export function dataProcessing(params: DataProcessingParams) { + return request("/v1/kefu/dataProcessing", params, "POST"); +} /** * AI文本生成接口 @@ -32,7 +69,7 @@ export async function generateAiText( Authorization: token ? `Bearer ${token}` : undefined, }, timeout: 30000, // AI生成可能需要更长时间 - } + }, ); // 新接口返回:{ code: 200, msg: 'success', data: '...公告内容...' } diff --git a/Touchkebao/src/store/module/weChat/weChat.ts b/Touchkebao/src/store/module/weChat/weChat.ts index 58ee18c1..5068f3c0 100644 --- a/Touchkebao/src/store/module/weChat/weChat.ts +++ b/Touchkebao/src/store/module/weChat/weChat.ts @@ -6,7 +6,7 @@ import { getGroupMembers, } from "@/pages/pc/ckbox/api"; import { WeChatState } from "./weChat.data"; - +import { dataProcessing, aiChat } from "@/api/ai"; import { likeListItem, CommentItem, @@ -312,6 +312,26 @@ export const useWeChatStore = create()( set(state => ({ currentMessages: [...state.currentMessages, message], })); + //把数据传到存客宝 + const params: any = { + type: "CmdNewMessage", + wechatAccountId: currentContract.wechatAccountId, + }; + if (isWechatGroup) { + params.chatroomMessage = [message]; + } else { + params.friendMessage = [message]; + } + const dataProcessingResult = await dataProcessing(params); + //如果成功,就请求ai对话接口 + if (dataProcessingResult) { + const messageContent = await aiChat({ + friendId: getMessageId, + wechatAccountId: currentContract.wechatAccountId, + message: message, + }); + console.log("ai对话接口返回", messageContent); + } } else { // 更新其他聊天的未读消息数 const chatSessions = useCkChatStore.getState().chatSessions;