正则相关
This commit is contained in:
@@ -201,7 +201,9 @@ class RegexService:
|
||||
placement: int,
|
||||
character_name: Optional[str] = None,
|
||||
preset_name: Optional[str] = None,
|
||||
message_depth: int = 0
|
||||
message_depth: int = 0,
|
||||
is_for_llm: bool = False, # ✅ 新增:是否发送给LLM
|
||||
is_markdown_rendered: bool = False # ✅ 新增:是否已Markdown渲染
|
||||
) -> str:
|
||||
"""
|
||||
根据 placement 应用正则规则
|
||||
@@ -212,6 +214,8 @@ class RegexService:
|
||||
character_name: 当前角色卡名称
|
||||
preset_name: 当前预设名称
|
||||
message_depth: 消息深度
|
||||
is_for_llm: 是否用于发送给 LLM(影响 promptOnly 逻辑)
|
||||
is_markdown_rendered: 是否是 Markdown 渲染后的内容(影响 markdownOnly 逻辑)
|
||||
|
||||
Returns:
|
||||
处理后的文本
|
||||
@@ -220,6 +224,14 @@ class RegexService:
|
||||
|
||||
result = text
|
||||
for rule in rules:
|
||||
# ✅ 检查 promptOnly:如果规则只应用于LLM,但当前不是LLM场景,则跳过
|
||||
if rule.promptOnly and not is_for_llm:
|
||||
continue
|
||||
|
||||
# ✅ 检查 markdownOnly:如果规则只应用于Markdown渲染,但当前不是渲染后,则跳过
|
||||
if rule.markdownOnly and not is_markdown_rendered:
|
||||
continue
|
||||
|
||||
# 检查此规则是否适用于当前 placement
|
||||
if placement not in [p.value for p in rule.placement]:
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user