From 0e229dffa6874b01a81249127b28216d23577bc6 Mon Sep 17 00:00:00 2001 From: SerenNoble Date: Sun, 28 Jun 2026 20:33:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20matcher=20=E6=8F=90=E7=A4=BA=E8=AF=8D?= =?UTF-8?q?=E8=A1=A5=20{conversation}=20=E5=8D=A0=E4=BD=8D=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit generateSummary 只替换 {conversation} 占位符,而 buildInstruction 没有它, 导致拼好的「聊天内容+候选角色」从没发给 LLM,全程幻觉。 补上占位符 + 收一下调试日志(不记录聊天原文)。 Co-Authored-By: Claude --- .../modules/agent/service/impl/PersonaMatcherServiceImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/PersonaMatcherServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/PersonaMatcherServiceImpl.java index e1a76fab5..e4f198135 100644 --- a/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/PersonaMatcherServiceImpl.java +++ b/main/manager-api/src/main/java/xiaozhi/modules/agent/service/impl/PersonaMatcherServiceImpl.java @@ -122,6 +122,7 @@ public class PersonaMatcherServiceImpl implements PersonaMatcherService { .filter(s -> s != null && !s.isBlank()) .collect(Collectors.joining("\n")); String conversation = buildConversation(topics, candidates, cur); + log.info("[persona-match] user={} 候选{}个 主题{}字符", userId, candidates.size(), topics.length()); String promptTemplate = buildInstruction(); String resp; try { @@ -172,7 +173,8 @@ public class PersonaMatcherServiceImpl implements PersonaMatcherService { private String buildInstruction() { return "你是儿童陪伴角色匹配器。根据【孩子近期聊天】从【候选陪伴角色】的编号列表里选最贴合的一个。" - + "若【当前角色】已足够合适,务必保留当前(孩子需要稳定陪伴)。仅当另一角色明显更贴合时才换。" + + "若【当前角色】已足够合适,务必保留当前(孩子需要稳定陪伴)。仅当另一角色明显更贴合时才换。\n\n" + + "{conversation}\n\n" + "只返回JSON,不要多余文字:{\"choice\":选中角色的编号(整数),\"score\":0.0到1.0,\"reason\":\"一句话\"}"; }