From 157f2bc0447ce956417f69699f58ecc324e24c95 Mon Sep 17 00:00:00 2001 From: HexatomicRing <54496918+HexatomicRing@users.noreply.github.com> Date: Fri, 11 Apr 2025 10:35:34 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B2=E6=AD=A2=E5=85=B3=E9=94=AE=E8=AF=8D?= =?UTF-8?q?=E5=92=8Cregex=E9=87=8D=E5=A4=8D=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reasoning_prompt_builder.py | 23 ++++++++++--------- .../think_flow_prompt_builder.py | 23 ++++++++++--------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/plugins/chat_module/reasoning_chat/reasoning_prompt_builder.py b/src/plugins/chat_module/reasoning_chat/reasoning_prompt_builder.py index 045045bae..75a876a9c 100644 --- a/src/plugins/chat_module/reasoning_chat/reasoning_prompt_builder.py +++ b/src/plugins/chat_module/reasoning_chat/reasoning_prompt_builder.py @@ -115,17 +115,18 @@ class PromptBuilder: f"检测到以下关键词之一:{rule.get('keywords', [])},触发反应:{rule.get('reaction', '')}" ) keywords_reaction_prompt += rule.get("reaction", "") + "," - for pattern in rule.get("regex", []): - result = pattern.search(message_txt) - if result: - reaction = rule.get('reaction', '') - for name, content in result.groupdict().items(): - reaction = reaction.replace(f'[{name}]', content) - logger.info( - f"匹配到以下正则表达式:{pattern},触发反应:{reaction}" - ) - keywords_reaction_prompt += reaction + "," - break + else: + for pattern in rule.get("regex", []): + result = pattern.search(message_txt) + if result: + reaction = rule.get('reaction', '') + for name, content in result.groupdict().items(): + reaction = reaction.replace(f'[{name}]', content) + logger.info( + f"匹配到以下正则表达式:{pattern},触发反应:{reaction}" + ) + keywords_reaction_prompt += reaction + "," + break # 中文高手(新加的好玩功能) prompt_ger = "" diff --git a/src/plugins/chat_module/think_flow_chat/think_flow_prompt_builder.py b/src/plugins/chat_module/think_flow_chat/think_flow_prompt_builder.py index 8938e2e78..7ae7940bb 100644 --- a/src/plugins/chat_module/think_flow_chat/think_flow_prompt_builder.py +++ b/src/plugins/chat_module/think_flow_chat/think_flow_prompt_builder.py @@ -61,17 +61,18 @@ class PromptBuilder: f"检测到以下关键词之一:{rule.get('keywords', [])},触发反应:{rule.get('reaction', '')}" ) keywords_reaction_prompt += rule.get("reaction", "") + "," - for pattern in rule.get("regex", []): - result = pattern.search(message_txt) - if result: - reaction = rule.get('reaction', '') - for name, content in result.groupdict().items(): - reaction = reaction.replace(f'[{name}]', content) - logger.info( - f"匹配到以下正则表达式:{pattern},触发反应:{reaction}" - ) - keywords_reaction_prompt += reaction + "," - break + else: + for pattern in rule.get("regex", []): + result = pattern.search(message_txt) + if result: + reaction = rule.get('reaction', '') + for name, content in result.groupdict().items(): + reaction = reaction.replace(f'[{name}]', content) + logger.info( + f"匹配到以下正则表达式:{pattern},触发反应:{reaction}" + ) + keywords_reaction_prompt += reaction + "," + break # 中文高手(新加的好玩功能) prompt_ger = ""