feat(chat): 增加已读标记以聚焦未读消息

为聊天上下文生成逻辑引入了“已读标记” (read_mark) 机制。

当生成回复时,可以在历史消息中插入一个明确的分隔符,以告知模型哪些消息是它已经看过的旧消息,哪些是需要关注的新消息。

这有助于模型更好地聚焦于未读内容,提升上下文感知能力和回复的相关性。

同时,将 Prompt 模板中的“群聊”等硬编码文本参数化,以更好地适配私聊等不同聊天场景。
This commit is contained in:
tt-P607
2025-09-23 15:24:28 +08:00
committed by Windpicker-owo
parent f515bf679e
commit f3b3e60c1c
5 changed files with 31 additions and 17 deletions

View File

@@ -86,6 +86,7 @@ async def generate_reply(
return_prompt: bool = False,
request_type: str = "generator_api",
from_plugin: bool = True,
read_mark: float = 0.0,
) -> Tuple[bool, List[Tuple[str, Any]], Optional[str]]:
"""生成回复
@@ -138,6 +139,7 @@ async def generate_reply(
from_plugin=from_plugin,
stream_id=chat_stream.stream_id if chat_stream else chat_id,
reply_message=reply_message,
read_mark=read_mark,
)
if not success:
logger.warning("[GeneratorAPI] 回复生成失败")