feat: add continue/new support to chat frontends
This commit is contained in:
@@ -5,6 +5,7 @@ sys.path.insert(0, PROJECT_ROOT)
|
||||
os.chdir(PROJECT_ROOT)
|
||||
from agentmain import GeneraticAgent
|
||||
from frontends.chatapp_common import format_restore
|
||||
from frontends.continue_cmd import handle_frontend_command as handle_continue_frontend, reset_conversation
|
||||
from llmcore import mykeys
|
||||
|
||||
import lark_oapi as lark
|
||||
@@ -508,11 +509,9 @@ def handle_command(open_id, cmd, chat_id=None):
|
||||
agent.abort()
|
||||
_send_cmd_response("正在停止...")
|
||||
elif cmd == "/new":
|
||||
agent.abort()
|
||||
agent.history = []
|
||||
_send_cmd_response("已清空当前共享上下文")
|
||||
_send_cmd_response(reset_conversation(agent))
|
||||
elif cmd == "/help":
|
||||
_send_cmd_response("命令列表:\n/stop - 停止当前任务\n/status - 查看状态\n/restore - 恢复上次对话历史\n/new - 开启新对话\n/help - 显示帮助")
|
||||
_send_cmd_response("命令列表:\n/stop - 停止当前任务\n/status - 查看状态\n/restore - 恢复上次对话历史\n/continue - 列出可恢复会话\n/continue [n] - 恢复第 n 个会话\n/new - 开启新对话并清空当前上下文\n/help - 显示帮助")
|
||||
elif cmd == "/status":
|
||||
_send_cmd_response(f"状态: {'空闲' if not agent.is_running else '运行中'}")
|
||||
elif cmd == "/restore":
|
||||
@@ -526,6 +525,8 @@ def handle_command(open_id, cmd, chat_id=None):
|
||||
_send_cmd_response(f"已恢复 {count} 轮对话\n来源: {fname}\n(仅恢复上下文,请输入新问题继续)")
|
||||
except Exception as e:
|
||||
_send_cmd_response(f"恢复失败: {e}")
|
||||
elif cmd.startswith("/continue"):
|
||||
_send_cmd_response(handle_continue_frontend(agent, cmd))
|
||||
else:
|
||||
_send_cmd_response(f"未知命令: {cmd}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user