fix: auto-fix code issues (cron)

- 修复重复导入/字段
- 修复异常处理
- 修复PEP8格式问题
- 添加类型注解
- 修复main.py中的语法错误(缺失try语句的from导入)
- 添加缺失的timedelta导入到plugin_manager.py
- 添加缺失的urllib.parse导入到plugin_manager.py和workflow_manager.py
- 添加缺失的os导入到document_processor.py
- 修复import排序问题
- 修复行长度超过100字符的问题
- 添加缺失的Alert导入到test_phase8_task8.py
- 添加缺失的get_export_manager导入到main.py
This commit is contained in:
AutoFix Bot
2026-03-04 09:27:30 +08:00
parent b000397dbe
commit 71b0d137d2
15 changed files with 80 additions and 18 deletions

View File

@@ -428,7 +428,8 @@ class AIManager:
文本: {text}
以 JSON 格式返回实体列表: [{{"text": "实体文本", "label": "类型", "start": 0, "end": 5, "confidence": 0.95}}]
以 JSON 格式返回实体列表: [{{"text": "实体文本", "label": "类型",
"start": 0, "end": 5, "confidence": 0.95}}]
只返回 JSON 数组,不要其他内容。"""
headers = {
@@ -603,7 +604,10 @@ class AIManager:
# Kimi 目前可能不支持真正的多模态,这里模拟返回
# 实际实现时需要根据 Kimi API 更新
content = f"图片 URL: {', '.join(image_urls)}\n\n{prompt}\n\n注意:请基于图片 URL 描述的内容进行回答。"
content = (
f"图片 URL: {', '.join(image_urls)}\n\n{prompt}\n\n"
"注意:请基于图片 URL 描述的内容进行回答。"
)
payload = {
"model": "k2p5",
@@ -1319,7 +1323,10 @@ class AIManager:
"mean": round(mean, 2),
"std": round(std, 2),
"confidence": min(0.95, 0.7 + len(historical_values) * 0.01),
"explanation": f"当前值偏离均值{z_score:.2f}个标准差,{'检测到异常' if is_anomaly else '处于正常范围'}",
"explanation": (
f"当前值偏离均值{z_score:.2f}个标准差,"
f"{'检测到异常' if is_anomaly else '处于正常范围'}"
),
}
def _predict_entity_growth(self, input_data: dict, model: PredictionModel) -> dict:
@@ -1349,7 +1356,10 @@ class AIManager:
"current_count": counts[-1],
"growth_rate": round(avg_growth_rate, 4),
"confidence": min(0.9, 0.6 + len(entity_history) * 0.03),
"explanation": f"基于过去{len(entity_history)}个周期的数据,预测增长率{avg_growth_rate * 100:.1f}%",
"explanation": (
f"基于过去{len(entity_history)}个周期的数据,"
f"预测增长率{avg_growth_rate * 100:.1f}%"
),
}
def _predict_relation_evolution(self, input_data: dict, model: PredictionModel) -> dict: