Merge pull request #153 from ViviqwerAsd/feat/fsapp-add-llm-command
feat(fsapp): add /llm command support for model switching
This commit is contained in:
@@ -588,18 +588,32 @@ def handle_command(open_id, cmd, chat_id=None):
|
|||||||
send_message(chat_id, content, receive_id_type="chat_id")
|
send_message(chat_id, content, receive_id_type="chat_id")
|
||||||
else:
|
else:
|
||||||
send_message(open_id, content)
|
send_message(open_id, content)
|
||||||
if cmd == "/stop":
|
parts = (cmd or "").split()
|
||||||
|
op = (parts[0] if parts else "").lower()
|
||||||
|
if op == "/stop":
|
||||||
if open_id in user_tasks:
|
if open_id in user_tasks:
|
||||||
user_tasks[open_id]["running"] = False
|
user_tasks[open_id]["running"] = False
|
||||||
agent.abort()
|
agent.abort()
|
||||||
_send_cmd_response("正在停止...")
|
_send_cmd_response("正在停止...")
|
||||||
elif cmd == "/new":
|
elif op == "/new":
|
||||||
_send_cmd_response(reset_conversation(agent))
|
_send_cmd_response(reset_conversation(agent))
|
||||||
elif cmd == "/help":
|
elif op == "/help":
|
||||||
_send_cmd_response("命令列表:\n/stop - 停止当前任务\n/status - 查看状态\n/restore - 恢复上次对话历史\n/continue - 列出可恢复会话\n/continue [n] - 恢复第 n 个会话\n/new - 开启新对话并清空当前上下文\n/help - 显示帮助")
|
_send_cmd_response("命令列表:\n/stop - 停止当前任务\n/status - 查看状态\n/llm - 查看当前模型列表\n/llm [n] - 切换到第 n 个模型\n/restore - 恢复上次对话历史\n/continue - 列出可恢复会话\n/continue [n] - 恢复第 n 个会话\n/new - 开启新对话并清空当前上下文\n/help - 显示帮助")
|
||||||
elif cmd == "/status":
|
elif op == "/status":
|
||||||
_send_cmd_response(f"状态: {'空闲' if not agent.is_running else '运行中'}")
|
llm = agent.get_llm_name() if agent.llmclient else "未配置"
|
||||||
elif cmd == "/restore":
|
_send_cmd_response(f"状态: {'🔴 运行中' if agent.is_running else '🟢 空闲'}\nLLM: [{agent.llm_no}] {llm}")
|
||||||
|
elif op == "/llm":
|
||||||
|
if not agent.llmclient:
|
||||||
|
return _send_cmd_response("❌ 当前没有可用的 LLM 配置")
|
||||||
|
if len(parts) > 1:
|
||||||
|
try:
|
||||||
|
agent.next_llm(int(parts[1]))
|
||||||
|
return _send_cmd_response(f"✅ 已切换到 [{agent.llm_no}] {agent.get_llm_name()}")
|
||||||
|
except Exception:
|
||||||
|
return _send_cmd_response(f"用法: /llm <0-{len(agent.list_llms()) - 1}>")
|
||||||
|
lines = [f"{'→' if cur else ' '} [{i}] {name}" for i, name, cur in agent.list_llms()]
|
||||||
|
_send_cmd_response("LLMs:\n" + "\n".join(lines))
|
||||||
|
elif op == "/restore":
|
||||||
try:
|
try:
|
||||||
restored_info, err = format_restore()
|
restored_info, err = format_restore()
|
||||||
if err:
|
if err:
|
||||||
@@ -610,7 +624,7 @@ def handle_command(open_id, cmd, chat_id=None):
|
|||||||
_send_cmd_response(f"已恢复 {count} 轮对话\n来源: {fname}\n(仅恢复上下文,请输入新问题继续)")
|
_send_cmd_response(f"已恢复 {count} 轮对话\n来源: {fname}\n(仅恢复上下文,请输入新问题继续)")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_send_cmd_response(f"恢复失败: {e}")
|
_send_cmd_response(f"恢复失败: {e}")
|
||||||
elif cmd.startswith("/continue"):
|
elif op == "/continue" or cmd.startswith("/continue"):
|
||||||
_send_cmd_response(handle_continue_frontend(agent, cmd))
|
_send_cmd_response(handle_continue_frontend(agent, cmd))
|
||||||
else:
|
else:
|
||||||
_send_cmd_response(f"未知命令: {cmd}")
|
_send_cmd_response(f"未知命令: {cmd}")
|
||||||
|
|||||||
Reference in New Issue
Block a user