From 4a88bf6aa3bfe5cbdc75a7d2d7ef57e26202ca1b Mon Sep 17 00:00:00 2001 From: zhaoyingbo Date: Mon, 2 Dec 2024 03:16:43 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=8E=9F=E5=A7=8B?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=A4=84=E7=90=86=E5=8A=9F=E8=83=BD=E4=BB=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=8F=90=E5=8F=8A=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/groupAgent/agent.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/controller/groupAgent/agent.ts b/controller/groupAgent/agent.ts index 3eebb34..721360c 100644 --- a/controller/groupAgent/agent.ts +++ b/controller/groupAgent/agent.ts @@ -8,7 +8,7 @@ const agent = async (ctx: Context.Data) => { requestId, larkCard, larkService, - larkBody: { messageId, msgText, chatId, mentions }, + larkBody: { messageId, msgText, chatId, mentions, rawMsgText }, } = ctx const cardGender = larkCard.child("groupAgent") // 回复一个loading的卡片 @@ -40,12 +40,20 @@ const agent = async (ctx: Context.Data) => { } logger.debug(`Chat history: ${JSON.stringify(chatHistory)}`) + // 根据Mention,拼装原始消息 + let userInput = rawMsgText + for (const mention of mentions ?? []) { + if (mention.id.user_id) { + userInput = userInput.replace(mention.key, mention.name) + } + } + // 调用大模型 try { const llmRes = await llm.invoke( "groupAgent", { - userInput: msgText, + userInput, chatHistory: JSON.stringify(chatHistory), time: new Date().toLocaleString("zh-CN", { timeZone: "Asia/Shanghai" }), },