feat: 重大功能更新 v1.4.0 - 飞书集成、AI语义相似度、前端优化
主要更新内容: - 🚀 飞书多维表格集成,支持工单数据同步 - 🤖 AI建议与人工描述语义相似度计算 - 🎨 前端UI全面优化,现代化设计 - 📊 智能知识库入库策略(AI准确率<90%使用人工描述) - 🔧 代码重构,模块化架构优化 - 📚 完整文档整合和更新 - 🐛 修复配置导入和数据库字段问题 技术特性: - 使用sentence-transformers进行语义相似度计算 - 快速模式结合TF-IDF和语义方法 - 响应式设计,支持移动端 - 加载状态和动画效果 - 配置化AI准确率阈值
This commit is contained in:
@@ -2,72 +2,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
增强版TSP助手 - 集成Agent功能
|
||||
这是一个真正的智能Agent实现
|
||||
重构版本:模块化设计,降低代码复杂度
|
||||
"""
|
||||
|
||||
import logging
|
||||
import asyncio
|
||||
from typing import Dict, Any, List, Optional
|
||||
from datetime import datetime
|
||||
import json
|
||||
|
||||
from src.main import TSPAssistant
|
||||
from src.agent import AgentCore, AgentState
|
||||
from src.agent.auto_monitor import AutoMonitorService
|
||||
from src.agent.intelligent_agent import IntelligentAgent, AlertContext, KnowledgeContext
|
||||
from src.agent.llm_client import LLMManager, LLMConfig
|
||||
from src.agent.action_executor import ActionExecutor
|
||||
from src.agent.agent_assistant_core import TSPAgentAssistantCore
|
||||
from src.agent.agent_message_handler import AgentMessageHandler
|
||||
from src.agent.agent_sample_actions import AgentSampleActions
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class TSPAgentAssistant(TSPAssistant):
|
||||
"""TSP Agent助手 - 增强版TSP助手,具备完整Agent功能"""
|
||||
class TSPAgentAssistant(TSPAgentAssistantCore):
|
||||
"""TSP Agent助手 - 重构版本"""
|
||||
|
||||
def __init__(self, llm_config: Optional[LLMConfig] = None):
|
||||
# 初始化基础TSP助手
|
||||
super().__init__()
|
||||
def __init__(self, llm_config=None):
|
||||
# 初始化核心功能
|
||||
super().__init__(llm_config)
|
||||
|
||||
# 初始化Agent核心
|
||||
self.agent_core = AgentCore()
|
||||
# 初始化消息处理器
|
||||
self.message_handler = AgentMessageHandler(self)
|
||||
|
||||
# 初始化自动监控服务
|
||||
self.auto_monitor = AutoMonitorService(self)
|
||||
# 初始化示例动作处理器
|
||||
self.sample_actions = AgentSampleActions(self)
|
||||
|
||||
# 初始化LLM客户端
|
||||
if llm_config:
|
||||
self.llm_manager = LLMManager(llm_config)
|
||||
else:
|
||||
# 使用默认配置 - 千问模型
|
||||
try:
|
||||
from config.llm_config import DEFAULT_CONFIG
|
||||
self.llm_manager = LLMManager(DEFAULT_CONFIG)
|
||||
except ImportError:
|
||||
# 如果配置文件不存在,使用内置配置
|
||||
default_config = LLMConfig(
|
||||
provider="openai",
|
||||
api_key="sk-your-qwen-api-key-here",
|
||||
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
|
||||
model="qwen-turbo",
|
||||
temperature=0.7,
|
||||
max_tokens=2000
|
||||
)
|
||||
self.llm_manager = LLMManager(default_config)
|
||||
|
||||
# 初始化智能Agent
|
||||
self.intelligent_agent = IntelligentAgent(self.llm_manager)
|
||||
|
||||
# 初始化动作执行器
|
||||
self.action_executor = ActionExecutor(self)
|
||||
|
||||
# Agent特有功能
|
||||
self.is_agent_mode = True
|
||||
self.proactive_tasks = []
|
||||
self.agent_memory = {}
|
||||
|
||||
# 添加一些示例执行历史(用于演示)
|
||||
self._add_sample_execution_history()
|
||||
|
||||
logger.info("TSP Agent助手初始化完成")
|
||||
logger.info("TSP Agent助手初始化完成(重构版本)")
|
||||
|
||||
async def process_message_agent(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user