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" }), },