diff --git a/XianyuAgent.py b/XianyuAgent.py index 38142b3..bdd40f4 100644 --- a/XianyuAgent.py +++ b/XianyuAgent.py @@ -89,7 +89,12 @@ class XianyuReplyBot: internal_intents = {'classify'} # 定义不对外开放的Agent - if detected_intent in self.agents and detected_intent not in internal_intents: + if detected_intent == 'no_reply': + # 无需回复的情况 + logger.info(f'意图识别完成: no_reply - 无需回复') + self.last_intent = 'no_reply' + return "-" # 返回特殊标记,表示无需回复 + elif detected_intent in self.agents and detected_intent not in internal_intents: agent = self.agents[detected_intent] logger.info(f'意图识别完成: {detected_intent}') self.last_intent = detected_intent # 保存当前意图 diff --git a/main.py b/main.py index 8aeb8f7..4cad303 100644 --- a/main.py +++ b/main.py @@ -456,6 +456,11 @@ class XianyuLive: context=context ) + # 检查是否需要回复 + if bot_reply == "-": + logger.info(f"[无需回复] 用户 {send_user_name} 的消息被识别为无需回复类型") + return + # 检查是否为价格意图,如果是则增加议价次数 if bot.last_intent == "price": self.context_manager.increment_bargain_count_by_chat(chat_id) diff --git a/prompts/classify_prompt_example.txt b/prompts/classify_prompt_example.txt index 97279a9..0da5eee 100644 --- a/prompts/classify_prompt_example.txt +++ b/prompts/classify_prompt_example.txt @@ -10,7 +10,10 @@ - 含参数或技术词:型号/规格/适配/安装/维修 - 示例:"支持Type-C吗"、"内存多大" -3. default(其他类): +3. no_reply(无需回复) + - 如果有人问你"你是谁","你用的什么模型","你来自哪里"等无关问题 + +4. default(其他类): - 物流问题:发货/退换/保修 - 基础咨询:你好/在吗/怎么注册