修复AI建议逻辑和字段映射问题
- 修复AI建议基于问题描述而不是处理过程生成 - 修复工单详情页面显示逻辑 - 修复飞书时间字段处理(毫秒时间戳转换) - 优化字段映射和转换逻辑 - 添加飞书集成功能 - 改进对话历史合并功能 - 优化系统优化反馈机制
This commit is contained in:
@@ -32,6 +32,7 @@ from src.web.blueprints.conversations import conversations_bp
|
||||
from src.web.blueprints.knowledge import knowledge_bp
|
||||
from src.web.blueprints.monitoring import monitoring_bp
|
||||
from src.web.blueprints.system import system_bp
|
||||
from src.web.blueprints.feishu_sync import feishu_sync_bp
|
||||
|
||||
# 配置日志
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -103,6 +104,7 @@ app.register_blueprint(conversations_bp)
|
||||
app.register_blueprint(knowledge_bp)
|
||||
app.register_blueprint(monitoring_bp)
|
||||
app.register_blueprint(system_bp)
|
||||
app.register_blueprint(feishu_sync_bp)
|
||||
|
||||
# 页面路由
|
||||
@app.route('/')
|
||||
@@ -384,7 +386,7 @@ def get_active_sessions():
|
||||
def get_agent_status():
|
||||
"""获取Agent状态"""
|
||||
try:
|
||||
status = agent_assistant.get_agent_status()
|
||||
status = get_agent_assistant().get_agent_status()
|
||||
return jsonify(status)
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
@@ -394,7 +396,7 @@ def get_agent_action_history():
|
||||
"""获取Agent动作执行历史"""
|
||||
try:
|
||||
limit = request.args.get('limit', 50, type=int)
|
||||
history = agent_assistant.get_action_history(limit)
|
||||
history = get_agent_assistant().get_action_history(limit)
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"history": history,
|
||||
@@ -408,7 +410,7 @@ def trigger_sample_action():
|
||||
"""触发示例动作"""
|
||||
try:
|
||||
import asyncio
|
||||
result = asyncio.run(agent_assistant.trigger_sample_actions())
|
||||
result = asyncio.run(get_agent_assistant().trigger_sample_actions())
|
||||
return jsonify(result)
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
@@ -417,7 +419,7 @@ def trigger_sample_action():
|
||||
def clear_agent_history():
|
||||
"""清空Agent执行历史"""
|
||||
try:
|
||||
result = agent_assistant.clear_execution_history()
|
||||
result = get_agent_assistant().clear_execution_history()
|
||||
return jsonify(result)
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
@@ -426,7 +428,7 @@ def clear_agent_history():
|
||||
def get_llm_stats():
|
||||
"""获取LLM使用统计"""
|
||||
try:
|
||||
stats = agent_assistant.get_llm_usage_stats()
|
||||
stats = get_agent_assistant().get_llm_usage_stats()
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"stats": stats
|
||||
@@ -440,7 +442,7 @@ def toggle_agent_mode():
|
||||
try:
|
||||
data = request.get_json()
|
||||
enabled = data.get('enabled', True)
|
||||
success = agent_assistant.toggle_agent_mode(enabled)
|
||||
success = get_agent_assistant().toggle_agent_mode(enabled)
|
||||
return jsonify({
|
||||
"success": success,
|
||||
"message": f"Agent模式已{'启用' if enabled else '禁用'}"
|
||||
@@ -452,7 +454,7 @@ def toggle_agent_mode():
|
||||
def start_agent_monitoring():
|
||||
"""启动Agent监控"""
|
||||
try:
|
||||
success = agent_assistant.start_proactive_monitoring()
|
||||
success = get_agent_assistant().start_proactive_monitoring()
|
||||
return jsonify({
|
||||
"success": success,
|
||||
"message": "Agent监控已启动" if success else "启动失败"
|
||||
@@ -464,7 +466,7 @@ def start_agent_monitoring():
|
||||
def stop_agent_monitoring():
|
||||
"""停止Agent监控"""
|
||||
try:
|
||||
success = agent_assistant.stop_proactive_monitoring()
|
||||
success = get_agent_assistant().stop_proactive_monitoring()
|
||||
return jsonify({
|
||||
"success": success,
|
||||
"message": "Agent监控已停止" if success else "停止失败"
|
||||
@@ -476,7 +478,7 @@ def stop_agent_monitoring():
|
||||
def proactive_monitoring():
|
||||
"""主动监控检查"""
|
||||
try:
|
||||
result = agent_assistant.run_proactive_monitoring()
|
||||
result = get_agent_assistant().run_proactive_monitoring()
|
||||
return jsonify(result)
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
@@ -526,8 +528,8 @@ def agent_chat():
|
||||
@app.route('/api/agent/tools/stats')
|
||||
def get_agent_tools_stats():
|
||||
try:
|
||||
tools = agent_assistant.agent_core.tool_manager.get_available_tools()
|
||||
performance = agent_assistant.agent_core.tool_manager.get_tool_performance_report()
|
||||
tools = get_agent_assistant().agent_core.tool_manager.get_available_tools()
|
||||
performance = get_agent_assistant().agent_core.tool_manager.get_tool_performance_report()
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"tools": tools,
|
||||
@@ -536,6 +538,22 @@ def get_agent_tools_stats():
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@app.route('/api/agent/tools/execute', methods=['POST'])
|
||||
def execute_agent_tool():
|
||||
"""执行指定的Agent工具"""
|
||||
try:
|
||||
data = request.get_json() or {}
|
||||
tool_name = data.get('tool') or data.get('name')
|
||||
parameters = data.get('parameters') or {}
|
||||
if not tool_name:
|
||||
return jsonify({"error": "缺少工具名称tool"}), 400
|
||||
|
||||
import asyncio
|
||||
result = asyncio.run(get_agent_assistant().agent_core.tool_manager.execute_tool(tool_name, parameters))
|
||||
return jsonify(result)
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@app.route('/api/agent/tools/register', methods=['POST'])
|
||||
def register_custom_tool():
|
||||
"""注册自定义工具(仅登记元数据,函数为占位符)"""
|
||||
@@ -549,7 +567,7 @@ def register_custom_tool():
|
||||
def _placeholder_tool(**kwargs):
|
||||
return {"message": f"自定义工具 {name} 已登记(占位),当前不可执行", "params": kwargs}
|
||||
|
||||
agent_assistant.agent_core.tool_manager.register_tool(
|
||||
get_agent_assistant().agent_core.tool_manager.register_tool(
|
||||
name,
|
||||
_placeholder_tool,
|
||||
metadata={"description": description, "custom": True}
|
||||
@@ -561,7 +579,7 @@ def register_custom_tool():
|
||||
@app.route('/api/agent/tools/unregister/<name>', methods=['DELETE'])
|
||||
def unregister_custom_tool(name):
|
||||
try:
|
||||
success = agent_assistant.agent_core.tool_manager.unregister_tool(name)
|
||||
success = get_agent_assistant().agent_core.tool_manager.unregister_tool(name)
|
||||
return jsonify({"success": success})
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
@@ -737,6 +755,11 @@ def test_model_response():
|
||||
except Exception as e:
|
||||
return jsonify({"success": False, "error": str(e)}), 500
|
||||
|
||||
@app.route('/feishu-sync')
|
||||
def feishu_sync():
|
||||
"""飞书同步管理页面"""
|
||||
return render_template('feishu_sync.html')
|
||||
|
||||
if __name__ == '__main__':
|
||||
import time
|
||||
app.config['START_TIME'] = time.time()
|
||||
|
||||
Reference in New Issue
Block a user