docs: update README and CLAUDE.md to v2.2.0

- Added documentation for audit tracking (IP address, invocation method).
- Updated database model descriptions for enhanced WorkOrder and Conversation fields.
- Documented the new UnifiedConfig system.
- Reflected enhanced logging transparency for knowledge base parsing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
zhaojie
2026-02-11 00:08:09 +08:00
parent 2026007045
commit c3560b43fd
218 changed files with 3354 additions and 5096 deletions

View File

@@ -1,178 +0,0 @@
# TSP智能助手配置说明
## 📋 配置文件概述
本目录包含TSP智能助手的核心配置文件包括LLM配置、集成配置等。
## 🤖 LLM配置
### 千问模型配置
本项目默认使用阿里云千问模型。要使用千问模型,请按以下步骤配置:
#### 1. 获取API密钥
1. 访问 [阿里云百炼平台](https://bailian.console.aliyun.com/)
2. 注册并登录账号
3. 创建应用并获取API密钥
#### 2. 配置API密钥
编辑 `config/llm_config.py` 文件,将 `api_key` 替换为您的实际API密钥
```python
QWEN_CONFIG = LLMConfig(
provider="openai",
api_key="sk-your-actual-qwen-api-key", # 替换为您的实际密钥
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
model="qwen-turbo",
temperature=0.7,
max_tokens=2000
)
```
#### 3. 可用的千问模型
- `qwen-turbo`: 快速响应,适合一般对话
- `qwen-plus`: 平衡性能和成本
- `qwen-max`: 最强性能,适合复杂任务
#### 4. 环境变量配置(可选)
您也可以使用环境变量来配置:
```bash
export QWEN_API_KEY="sk-your-actual-qwen-api-key"
export QWEN_MODEL="qwen-turbo"
```
#### 5. 其他模型支持
项目也支持其他LLM提供商
- **OpenAI**: GPT-3.5/GPT-4
- **Anthropic**: Claude系列
- **本地模型**: Ollama等
#### 6. 配置验证
启动系统后可以在Agent管理页面查看LLM使用统计确认配置是否正确。
## 📱 飞书集成配置
### 配置文件说明
`integrations_config.json` 文件包含飞书集成的所有配置信息:
```json
{
"feishu": {
"app_id": "cli_a8b50ec0eed1500d",
"app_secret": "ccxkE7ZCFQZcwkkM1rLy0ccZRXYsT2xK",
"app_token": "XXnEbiCmEaMblSs6FDJcFCqsnIg",
"table_id": "tblnl3vJPpgMTSiP",
"last_updated": "2025-09-19T18:27:40.579958",
"status": "active"
},
"system": {
"sync_limit": 10,
"ai_suggestions_enabled": true,
"auto_sync_interval": 0,
"last_sync_time": null
}
}
```
### 配置参数说明
#### 飞书应用配置
- `app_id`: 飞书应用ID
- `app_secret`: 飞书应用密钥
- `app_token`: 飞书多维表格应用Token
- `table_id`: 飞书多维表格ID
- `last_updated`: 最后更新时间
- `status`: 集成状态active/inactive
#### 系统配置
- `sync_limit`: 同步记录数量限制
- `ai_suggestions_enabled`: 是否启用AI建议
- `auto_sync_interval`: 自动同步间隔(分钟)
- `last_sync_time`: 最后同步时间
### 获取飞书配置
1. **获取应用凭证**
- 访问 [飞书开放平台](https://open.feishu.cn/)
- 创建企业自建应用
- 获取 `app_id``app_secret`
2. **获取表格信息**
- 打开飞书多维表格
- 从URL中提取 `app_token``table_id`
- 例如:`https://my-ichery.feishu.cn/base/XXnEbiCmEaMblSs6FDJcFCqsnIg?table=tblnl3vJPpgMTSiP`
- `app_token`: `XXnEbiCmEaMblSs6FDJcFCqsnIg`
- `table_id`: `tblnl3vJPpgMTSiP`
3. **配置权限**
- 在飞书开放平台中配置应用权限
- 确保应用有读取多维表格的权限
### 字段映射配置
系统会自动映射以下飞书字段到本地数据库:
| 飞书字段 | 本地字段 | 类型 | 说明 |
|---------|---------|------|------|
| TR Number | order_id | String | 工单编号 |
| TR Description | description | Text | 工单描述 |
| Type of problem | category | String | 问题类型 |
| TR Level | priority | String | 优先级 |
| TR Status | status | String | 工单状态 |
| Source | source | String | 来源 |
| Created by | created_by | String | 创建人 |
| Module模块 | module | String | 模块 |
| Wilfulness责任人 | wilfulness | String | 责任人 |
| Date of close TR | date_of_close | DateTime | 关闭日期 |
| Vehicle Type01 | vehicle_type | String | 车型 |
| VIN\|sim | vin_sim | String | 车架号/SIM |
| App remote control version | app_remote_control_version | String | 应用远程控制版本 |
| HMI SW | hmi_sw | String | HMI软件版本 |
| 父记录 | parent_record | String | 父记录 |
| Has it been updated on the same day | has_updated_same_day | String | 是否同日更新 |
| Operating time | operating_time | String | 操作时间 |
## 🔧 配置管理
### 配置文件位置
- `llm_config.py`: LLM客户端配置
- `integrations_config.json`: 集成服务配置
- `integrations_config copy.json`: 配置备份文件
### 配置更新
- 修改配置文件后需要重启服务
- 建议在修改前备份配置文件
- 可以通过Web界面进行部分配置的在线修改
### 环境变量支持
系统支持通过环境变量覆盖配置文件设置:
```bash
# LLM配置
export LLM_PROVIDER="openai"
export LLM_API_KEY="your-api-key"
export LLM_MODEL="gpt-3.5-turbo"
# 飞书配置
export FEISHU_APP_ID="your-app-id"
export FEISHU_APP_SECRET="your-app-secret"
export FEISHU_APP_TOKEN="your-app-token"
export FEISHU_TABLE_ID="your-table-id"
```
## 🚨 注意事项
1. **安全性**: 配置文件包含敏感信息,请勿提交到版本控制系统
2. **备份**: 修改配置前请备份原文件
3. **权限**: 确保飞书应用有足够的权限访问多维表格
4. **测试**: 配置完成后建议先进行测试同步
5. **监控**: 定期检查同步状态和错误日志

View File

@@ -1,110 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
AI准确率配置
管理AI建议的准确率阈值和相关配置
"""
from dataclasses import dataclass
from typing import Dict, Any
@dataclass
class AIAccuracyConfig:
"""AI准确率配置类"""
# 相似度阈值配置
auto_approve_threshold: float = 0.95 # 自动审批阈值≥95%
use_human_resolution_threshold: float = 0.90 # 使用人工描述阈值(<90%
manual_review_threshold: float = 0.80 # 人工审核阈值≥80%
# 置信度配置
ai_suggestion_confidence: float = 0.95 # AI建议默认置信度
human_resolution_confidence: float = 0.90 # 人工描述置信度
# 入库策略配置
prefer_human_when_low_accuracy: bool = True # 当AI准确率低时优先使用人工描述
enable_auto_approval: bool = True # 是否启用自动审批
enable_human_fallback: bool = True # 是否启用人工描述回退
def get_threshold_explanation(self, similarity: float) -> str:
"""获取相似度阈值的解释"""
if similarity >= self.auto_approve_threshold:
return f"相似度≥{self.auto_approve_threshold*100:.0f}%自动审批使用AI建议"
elif similarity >= self.manual_review_threshold:
return f"相似度≥{self.manual_review_threshold*100:.0f}%,建议人工审核"
elif similarity >= self.use_human_resolution_threshold:
return f"相似度<{self.use_human_resolution_threshold*100:.0f}%,建议使用人工描述"
else:
return f"相似度<{self.use_human_resolution_threshold*100:.0f}%,优先使用人工描述"
def should_use_human_resolution(self, similarity: float) -> bool:
"""判断是否应该使用人工描述"""
return similarity < self.use_human_resolution_threshold
def should_auto_approve(self, similarity: float) -> bool:
"""判断是否应该自动审批"""
return similarity >= self.auto_approve_threshold and self.enable_auto_approval
def get_confidence_score(self, similarity: float, use_human: bool = False) -> float:
"""获取置信度分数"""
if use_human:
return self.human_resolution_confidence
else:
return max(similarity, self.ai_suggestion_confidence)
def to_dict(self) -> Dict[str, Any]:
"""转换为字典格式"""
return {
"auto_approve_threshold": self.auto_approve_threshold,
"use_human_resolution_threshold": self.use_human_resolution_threshold,
"manual_review_threshold": self.manual_review_threshold,
"ai_suggestion_confidence": self.ai_suggestion_confidence,
"human_resolution_confidence": self.human_resolution_confidence,
"prefer_human_when_low_accuracy": self.prefer_human_when_low_accuracy,
"enable_auto_approval": self.enable_auto_approval,
"enable_human_fallback": self.enable_human_fallback
}
@classmethod
def from_dict(cls, data: Dict[str, Any]) -> 'AIAccuracyConfig':
"""从字典创建配置"""
return cls(**data)
# 默认配置实例
DEFAULT_CONFIG = AIAccuracyConfig()
# 配置预设
PRESETS = {
"conservative": AIAccuracyConfig(
auto_approve_threshold=0.98,
use_human_resolution_threshold=0.85,
manual_review_threshold=0.90,
human_resolution_confidence=0.95
),
"balanced": AIAccuracyConfig(
auto_approve_threshold=0.95,
use_human_resolution_threshold=0.90,
manual_review_threshold=0.80,
human_resolution_confidence=0.90
),
"aggressive": AIAccuracyConfig(
auto_approve_threshold=0.90,
use_human_resolution_threshold=0.80,
manual_review_threshold=0.70,
human_resolution_confidence=0.85
)
}
def get_accuracy_config(preset: str = "balanced") -> AIAccuracyConfig:
"""获取准确率配置"""
return PRESETS.get(preset, DEFAULT_CONFIG)
def update_accuracy_config(config: AIAccuracyConfig) -> bool:
"""更新准确率配置(可以保存到文件或数据库)"""
try:
# 这里可以实现配置的持久化存储
# 例如保存到配置文件或数据库
return True
except Exception:
return False

View File

@@ -1,16 +0,0 @@
{
"feishu": {
"app_id": "tblnl3vJPpgMTSiP",
"app_secret": "ccxkE7ZCFQZcwkkM1rLy0ccZRXYsT2xK",
"app_token": "XXnEbiCmEaMblSs6FDJcFCqsnlg",
"table_id": "tblnl3vJPpgMTSiP",
"last_updated": null,
"status": "inactive"
},
"system": {
"sync_limit": 10,
"ai_suggestions_enabled": true,
"auto_sync_interval": 0,
"last_sync_time": null
}
}

View File

@@ -1,16 +0,0 @@
{
"feishu": {
"app_id": "cli_a8b50ec0eed1500d",
"app_secret": "ccxkE7ZCFQZcwkkM1rLy0ccZRXYsT2xK",
"app_token": "XXnEbiCmEaMblSs6FDJcFCqsnIg",
"table_id": "tblnl3vJPpgMTSiP",
"last_updated": "2025-09-19T18:40:55.291113",
"status": "active"
},
"system": {
"sync_limit": 10,
"ai_suggestions_enabled": true,
"auto_sync_interval": 0,
"last_sync_time": null
}
}

View File

@@ -1,60 +0,0 @@
# -*- coding: utf-8 -*-
"""
LLM配置文件 - 千问模型配置
"""
from src.agent.llm_client import LLMConfig
# 千问模型配置
QWEN_CONFIG = LLMConfig(
provider="qwen",
api_key="sk-c0dbefa1718d46eaa897199135066f00", # 请替换为您的千问API密钥
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
model="qwen-plus-latest", # 可选: qwen-turbo, qwen-plus, qwen-max
temperature=0.7,
max_tokens=2000
)
# 其他模型配置示例
OPENAI_CONFIG = LLMConfig(
provider="openai",
api_key="sk-your-openai-api-key-here",
model="gpt-3.5-turbo",
temperature=0.7,
max_tokens=2000
)
ANTHROPIC_CONFIG = LLMConfig(
provider="anthropic",
api_key="sk-ant-your-anthropic-api-key-here",
model="claude-3-sonnet-20240229",
temperature=0.7,
max_tokens=2000
)
# 默认使用千问模型
DEFAULT_CONFIG = QWEN_CONFIG
def get_default_llm_config() -> LLMConfig:
"""
获取默认的LLM配置
优先从统一配置管理器获取,如果失败则使用本地配置
"""
try:
from src.config.unified_config import get_config
config = get_config()
llm_dict = config.get_llm_config()
# 创建LLMConfig对象
return LLMConfig(
provider=llm_dict.get("provider", "qwen"),
api_key=llm_dict.get("api_key", ""),
base_url=llm_dict.get("base_url", "https://dashscope.aliyuncs.com/compatible-mode/v1"),
model=llm_dict.get("model", "qwen-plus-latest"),
temperature=llm_dict.get("temperature", 0.7),
max_tokens=llm_dict.get("max_tokens", 2000)
)
except Exception:
# 如果统一配置不可用,使用本地配置
return DEFAULT_CONFIG

View File

@@ -1,52 +0,0 @@
{
"database": {
"url": "mysql+pymysql://tsp_assistant:password@jeason.online/tsp_assistant?charset=utf8mb4",
"pool_size": 10,
"max_overflow": 20,
"pool_timeout": 30,
"pool_recycle": 3600
},
"llm": {
"provider": "qwen",
"api_key": "sk-c0dbefa1718d46eaa897199135066f00",
"base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
"model": "qwen-plus-latest",
"temperature": 0.7,
"max_tokens": 2000,
"timeout": 30
},
"server": {
"host": "0.0.0.0",
"port": 5000,
"websocket_port": 8765,
"debug": false,
"log_level": "INFO"
},
"feishu": {
"app_id": "",
"app_secret": "",
"app_token": "",
"table_id": "",
"status": "active",
"sync_limit": 10,
"auto_sync_interval": 0
},
"ai_accuracy": {
"auto_approve_threshold": 0.95,
"use_human_resolution_threshold": 0.9,
"manual_review_threshold": 0.8,
"ai_suggestion_confidence": 0.95,
"human_resolution_confidence": 0.9,
"prefer_human_when_low_accuracy": true,
"enable_auto_approval": true,
"enable_human_fallback": true
},
"system": {
"backup_enabled": true,
"backup_interval": 24,
"max_backup_files": 7,
"cache_enabled": true,
"cache_ttl": 3600,
"monitoring_enabled": true
}
}