/resume prompt优化(v5) + wechatapp去or空占位 + summary截断80
This commit is contained in:
1 parent
26d5fc6781
commit
1bf2a530b9
3 files changed
+4
-4
No files matched your search
+1
-1
@@ -121,7 +121,7 @@ class GeneraticAgent:
|
||||
display_queue.put({'done': smart_format(f"✅ session.{k} = {repr(v)}", max_str_len=500), 'source': 'system'})
|
||||
return None
|
||||
if raw_query.strip() == '/resume':
|
||||
return r'扫temp/model_responses/下时间最近的10个文件(除本PID),读取每个文件content后先replace("\\n","\n").replace("\\r","\r")统一为真换行,再用re.findall(r"<history>\n\[(?:USER|Agent)\].*?</history>", content, re.DOTALL)提取,取每文件最后一个匹配作为该会话内容,按mtime倒序,每个用一句话总结聊了什么让我选择;选定后再简单读该文件末尾作为聊天基础'
|
||||
return r'帮我看看最近有哪些会话可以恢复。读model_responses/目录,按修改时间取最近10个文件,从每个文件里找最后一个<history>...</history>块,用一句话总结每个会话在聊什么,列表给我选。注意读文件后要把字面的\n替换成真换行才能正确匹配。'
|
||||
return raw_query
|
||||
|
||||
def run(self):
|
||||
|
||||
@@ -290,7 +290,7 @@ def _clean(t):
|
||||
for p in _TAG_PATS:
|
||||
t = re.sub(p, '', t, flags=re.DOTALL)
|
||||
t = re.sub(r'</?summary>', '', t)
|
||||
return re.sub(r'\n{3,}', '\n\n', _strip_md(t)).strip() or '...'
|
||||
return re.sub(r'\n{3,}', '\n\n', _strip_md(t)).strip()
|
||||
|
||||
def _turn_parts(t):
|
||||
_ph = []
|
||||
@@ -330,7 +330,7 @@ def on_message(bot, msg):
|
||||
return
|
||||
|
||||
def _handle():
|
||||
prompt = f"If you need to show files to user, use [FILE:filepath] in your response.\n\n{text}"
|
||||
prompt = text if text.startswith('/') else f"If you need to show files to user, use [FILE:filepath] in your response.\n\n{text}"
|
||||
dq = agent.put_task(prompt, source="wechat")
|
||||
try: bot.send_typing(uid)
|
||||
except: pass
|
||||
|
||||
@@ -546,7 +546,7 @@ class GenericAgentHandler(BaseHandler):
|
||||
summary = f"调用工具{tool_name}, args: {clean_args}"
|
||||
if tool_name == 'no_tool': summary = "直接回答了用户问题"
|
||||
next_prompt += "\n\n\nUSER: <summary>呢???!\n\n"
|
||||
summary = smart_format(summary.replace('\n', ''), max_str_len=100)
|
||||
summary = smart_format(summary.replace('\n', ''), max_str_len=80)
|
||||
self.history_info.append(f'[Agent] {summary}')
|
||||
_plan = self._in_plan_mode()
|
||||
if turn % 65 == 0 and (not _plan):
|
||||
|
||||
Reference in new issue
Block a user