diff --git a/agentmain.py b/agentmain.py index 5bafc21c..b8824d13 100644 --- a/agentmain.py +++ b/agentmain.py @@ -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"\n\[(?:USER|Agent)\].*?", content, re.DOTALL)提取,取每文件最后一个匹配作为该会话内容,按mtime倒序,每个用一句话总结聊了什么让我选择;选定后再简单读该文件末尾作为聊天基础' + return r'帮我看看最近有哪些会话可以恢复。读model_responses/目录,按修改时间取最近10个文件,从每个文件里找最后一个...块,用一句话总结每个会话在聊什么,列表给我选。注意读文件后要把字面的\n替换成真换行才能正确匹配。' return raw_query def run(self): diff --git a/frontends/wechatapp.py b/frontends/wechatapp.py index b017913a..5192a545 100644 --- a/frontends/wechatapp.py +++ b/frontends/wechatapp.py @@ -290,7 +290,7 @@ def _clean(t): for p in _TAG_PATS: t = re.sub(p, '', t, flags=re.DOTALL) t = re.sub(r'', '', 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 diff --git a/ga.py b/ga.py index c5b4a6ba..ca55ae66 100644 --- a/ga.py +++ b/ga.py @@ -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: 呢???!\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):