基本完成,舒适性修补

This commit is contained in:
2026-05-10 00:09:29 +08:00
parent 9faccc2c03
commit d6745b45a5
78 changed files with 3133 additions and 8850 deletions

View File

@@ -847,7 +847,8 @@ class ChatWorkflowService:
character,
chat_history,
user_message,
active_entries
active_entries,
comp_type # ✅ 传递组件类型
)
if debug_prompt:
@@ -895,7 +896,8 @@ class ChatWorkflowService:
character,
chat_history: List,
user_message: str,
active_entries: List
active_entries: List,
component_type: str = 'system' # ✅ 新增组件类型system/user/assistant
) -> str:
"""
处理组件内容,替换模板变量
@@ -917,6 +919,7 @@ class ChatWorkflowService:
chat_history: 聊天历史
user_message: 用户输入
active_entries: 激活的世界书条目
component_type: 组件类型system/user/assistant
Returns:
str: 处理后的内容
@@ -943,6 +946,23 @@ class ChatWorkflowService:
world_info_text = self._format_world_info(active_entries)
content = content.replace('{{world_info}}', world_info_text)
# ✅ 应用 System Prompt 正则规则placement=0
if component_type == 'system':
from services.regex_service import regex_service
from models.regex_rules import RegexPlacement
# 获取预设名称
# TODO: 这里应该从请求数据中获取 preset_name暂时传 None
content = regex_service.apply_rules_by_placement(
text=content,
placement=RegexPlacement.SYSTEM_PROMPT.value,
character_name=getattr(character, 'name', None),
preset_name=None, # TODO: 从请求中获取
message_depth=0,
is_for_llm=True, # ✅ 系统提示词会发送给 LLM
is_markdown_rendered=False
)
return content
def _format_chat_history(self, chat_history: List) -> str: