improve /resume: use regex to extract history blocks instead of naive tail reading

This commit is contained in:
Liang Jiaqing
2026-04-19 17:15:38 +08:00
parent 745220e62c
commit 2d753a6930

View File

@@ -109,7 +109,7 @@ class GeneraticAgent:
display_queue.put({'done': smart_format(f"✅ session.{k} = {repr(v)}", max_str_len=500), 'source': 'system'}) display_queue.put({'done': smart_format(f"✅ session.{k} = {repr(v)}", max_str_len=500), 'source': 'system'})
return None return None
if raw_query.strip() == '/resume': if raw_query.strip() == '/resume':
return '简单看看model_responses中的最近几次对话结尾部分(除了本次),分别简单总结一下让我选择,然后你简单阅读了解情况后作为我们接下来聊天基础' return r'用re.findall(r"<history>\\n\[(?:USER\|Agent)\].*?</history>", content, re.DOTALL) 扫temp/model_responses/下各文件(除本PID),取每文件最后一个匹配(注意JSON里换行是字面\\n)作为该会话内容按mtime倒序每个用一句话总结聊了什么让我选择选定后再简单读该文件末尾作为聊天基础'
return raw_query return raw_query
def run(self): def run(self):