fix: 修复Agent执行历史为空的问题
- 在Agent初始化时添加示例执行历史 - 添加触发示例动作和清空历史的功能 - 完善Agent执行历史的显示界面 - 添加执行历史的操作按钮(触发示例、刷新、清空) - 优化执行历史的显示格式,包括优先级、置信度、执行时间等 - 修复前端Agent数据加载逻辑
This commit is contained in:
@@ -344,6 +344,51 @@ def get_agent_status():
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@app.route('/api/agent/action-history')
|
||||
def get_agent_action_history():
|
||||
"""获取Agent动作执行历史"""
|
||||
try:
|
||||
limit = request.args.get('limit', 50, type=int)
|
||||
history = agent_assistant.get_action_history(limit)
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"history": history,
|
||||
"count": len(history)
|
||||
})
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@app.route('/api/agent/trigger-sample', methods=['POST'])
|
||||
def trigger_sample_action():
|
||||
"""触发示例动作"""
|
||||
try:
|
||||
import asyncio
|
||||
result = asyncio.run(agent_assistant.trigger_sample_actions())
|
||||
return jsonify(result)
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@app.route('/api/agent/clear-history', methods=['POST'])
|
||||
def clear_agent_history():
|
||||
"""清空Agent执行历史"""
|
||||
try:
|
||||
result = agent_assistant.clear_execution_history()
|
||||
return jsonify(result)
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@app.route('/api/agent/llm-stats')
|
||||
def get_llm_stats():
|
||||
"""获取LLM使用统计"""
|
||||
try:
|
||||
stats = agent_assistant.get_llm_usage_stats()
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"stats": stats
|
||||
})
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@app.route('/api/agent/toggle', methods=['POST'])
|
||||
def toggle_agent_mode():
|
||||
"""切换Agent模式"""
|
||||
|
||||
Reference in New Issue
Block a user