diff --git a/backend/knowledge_reasoner.py b/backend/knowledge_reasoner.py index 1a84dea..b1d8d10 100644 --- a/backend/knowledge_reasoner.py +++ b/backend/knowledge_reasoner.py @@ -124,7 +124,7 @@ class KnowledgeReasoner: if json_match: try: return json.loads(json_match.group()) - except BaseException: + except (json.JSONDecodeError, KeyError): pass return {"type": "factual", "entities": [], "intent": "general", "complexity": "simple"} @@ -178,7 +178,7 @@ class KnowledgeReasoner: related_entities=[], gaps=data.get("knowledge_gaps", []), ) - except BaseException: + except (json.JSONDecodeError, KeyError): pass return ReasoningResult( @@ -232,7 +232,7 @@ class KnowledgeReasoner: related_entities=[], gaps=data.get("knowledge_gaps", []), ) - except BaseException: + except (json.JSONDecodeError, KeyError): pass return ReasoningResult( @@ -286,7 +286,7 @@ class KnowledgeReasoner: related_entities=[], gaps=data.get("knowledge_gaps", []), ) - except BaseException: + except (json.JSONDecodeError, KeyError): pass return ReasoningResult( @@ -340,7 +340,7 @@ class KnowledgeReasoner: related_entities=[], gaps=data.get("knowledge_gaps", []), ) - except BaseException: + except (json.JSONDecodeError, KeyError): pass return ReasoningResult( @@ -360,8 +360,6 @@ class KnowledgeReasoner: 使用 BFS 在关系图中搜索路径 """ - # 实体数据可用于调试或扩展功能 - _ = {e["id"]: e for e in graph_data.get("entities", [])} relations = graph_data.get("relations", []) # 构建邻接表 @@ -483,7 +481,7 @@ class KnowledgeReasoner: if json_match: try: return json.loads(json_match.group()) - except BaseException: + except (json.JSONDecodeError, KeyError): pass return { diff --git a/backend/search_manager.py b/backend/search_manager.py index e0331fc..f92564c 100644 --- a/backend/search_manager.py +++ b/backend/search_manager.py @@ -36,7 +36,6 @@ try: except ImportError: SENTENCE_TRANSFORMERS_AVAILABLE = False - # ==================== 数据模型 ==================== @dataclass diff --git a/backend/test_multimodal.py b/backend/test_multimodal.py index d009ab6..a5af2ff 100644 --- a/backend/test_multimodal.py +++ b/backend/test_multimodal.py @@ -46,7 +46,7 @@ print("\n2. 测试模块初始化...") try: processor = get_multimodal_processor() - print(f" ✓ MultimodalProcessor 初始化成功") + print(" ✓ MultimodalProcessor 初始化成功") print(f" - 临时目录: {processor.temp_dir}") print(f" - 帧提取间隔: {processor.frame_interval}秒") except Exception as e: @@ -54,14 +54,14 @@ except Exception as e: try: img_processor = get_image_processor() - print(f" ✓ ImageProcessor 初始化成功") + print(" ✓ ImageProcessor 初始化成功") print(f" - 临时目录: {img_processor.temp_dir}") except Exception as e: print(f" ✗ ImageProcessor 初始化失败: {e}") try: linker = get_multimodal_entity_linker() - print(f" ✓ MultimodalEntityLinker 初始化成功") + print(" ✓ MultimodalEntityLinker 初始化成功") print(f" - 相似度阈值: {linker.similarity_threshold}") except Exception as e: print(f" ✗ MultimodalEntityLinker 初始化失败: {e}") diff --git a/backend/test_phase7_task6_8.py b/backend/test_phase7_task6_8.py index 418eed0..7cddc03 100644 --- a/backend/test_phase7_task6_8.py +++ b/backend/test_phase7_task6_8.py @@ -157,8 +157,8 @@ def test_cache_manager(): print(" ✓ 设置缓存 test_key_1") # 获取缓存 - value = cache.get("test_key_1") - print(f" ✓ 获取缓存: {value}") + _ = cache.get("test_key_1") + print(" ✓ 获取缓存: {value}") # 批量操作 cache.set_many({ @@ -168,8 +168,8 @@ def test_cache_manager(): }, ttl=60) print(" ✓ 批量设置缓存") - values = cache.get_many(["batch_key_1", "batch_key_2", "batch_key_3"]) - print(f" ✓ 批量获取缓存: {len(values)} 个") + _ = cache.get_many(["batch_key_1", "batch_key_2", "batch_key_3"]) + print(" ✓ 批量获取缓存: {len(values)} 个") # 删除缓存 cache.delete("test_key_1") @@ -177,7 +177,7 @@ def test_cache_manager(): # 获取统计 stats = cache.get_stats() - print(f"\n3. 缓存统计:") + print("\n3. 缓存统计:") print(f" 总请求数: {stats['total_requests']}") print(f" 命中数: {stats['hits']}") print(f" 未命中数: {stats['misses']}") @@ -216,16 +216,16 @@ def test_task_queue(): task_type="test_task", payload={"test": "data", "timestamp": time.time()} ) - print(f" ✓ 提交任务: {task_id}") + print(" ✓ 提交任务: {task_id}") # 获取任务状态 task_info = queue.get_status(task_id) if task_info: - print(f" ✓ 任务状态: {task_info.status}") + print(" ✓ 任务状态: {task_info.status}") # 获取统计 stats = queue.get_stats() - print(f"\n3. 任务队列统计:") + print("\n3. 任务队列统计:") print(f" 后端: {stats['backend']}") print(f" 按状态统计: {stats.get('by_status', {})}") @@ -287,7 +287,7 @@ def test_search_manager(): manager = get_search_manager() print("\n1. 搜索管理器初始化...") - print(f" ✓ 搜索管理器已初始化") + print(" ✓ 搜索管理器已初始化") print("\n2. 获取搜索统计...") stats = manager.get_search_stats() @@ -308,7 +308,7 @@ def test_performance_manager(): manager = get_performance_manager() print("\n1. 性能管理器初始化...") - print(f" ✓ 性能管理器已初始化") + print(" ✓ 性能管理器已初始化") print("\n2. 获取系统健康状态...") health = manager.get_health_status() diff --git a/backend/test_phase8_task1.py b/backend/test_phase8_task1.py index 1a745b4..0c33bf0 100644 --- a/backend/test_phase8_task1.py +++ b/backend/test_phase8_task1.py @@ -94,7 +94,7 @@ def test_domain_management(tenant_id: str): # 2. 获取验证指导 print("\n2.2 获取域名验证指导...") instructions = manager.get_domain_verification_instructions(domain.id) - print(f"✅ 验证指导:") + print("✅ 验证指导:") print(f" - DNS 记录: {instructions['dns_record']}") print(f" - 文件验证: {instructions['file_verification']}") @@ -141,7 +141,7 @@ def test_branding_management(tenant_id: str): custom_js="console.log('Custom JS loaded');", login_page_bg="https://example.com/bg.jpg" ) - print(f"✅ 品牌配置更新成功") + print("✅ 品牌配置更新成功") print(f" - Logo: {branding.logo_url}") print(f" - 主色: {branding.primary_color}") print(f" - 次色: {branding.secondary_color}") @@ -150,7 +150,7 @@ def test_branding_management(tenant_id: str): print("\n3.2 获取品牌配置...") fetched = manager.get_branding(tenant_id) assert fetched is not None, "获取品牌配置失败" - print(f"✅ 获取品牌配置成功") + print("✅ 获取品牌配置成功") # 3. 生成品牌 CSS print("\n3.3 生成品牌 CSS...") @@ -246,7 +246,7 @@ def test_usage_tracking(tenant_id: str): # 2. 获取使用统计 print("\n5.2 获取使用统计...") stats = manager.get_usage_stats(tenant_id) - print(f"✅ 使用统计:") + print("✅ 使用统计:") print(f" - 存储: {stats['storage_mb']:.2f} MB") print(f" - 转录: {stats['transcription_minutes']:.2f} 分钟") print(f" - API 调用: {stats['api_calls']}") diff --git a/backend/test_phase8_task2.py b/backend/test_phase8_task2.py index b090af4..95b353b 100644 --- a/backend/test_phase8_task2.py +++ b/backend/test_phase8_task2.py @@ -96,7 +96,7 @@ def test_subscription_manager(): # 获取用量汇总 summary = manager.get_usage_summary(tenant_id) - print(f"✓ 用量汇总:") + print("✓ 用量汇总:") print(f" - 总费用: ¥{summary['total_cost']:.2f}") for resource, data in summary['breakdown'].items(): print(f" - {resource}: {data['quantity']} (¥{data['cost']:.2f})") diff --git a/backend/test_phase8_task6.py b/backend/test_phase8_task6.py index 29f6b3f..4b025cd 100644 --- a/backend/test_phase8_task6.py +++ b/backend/test_phase8_task6.py @@ -649,7 +649,7 @@ console.log('Upload complete:', result.id); try: if self.created_ids['developer']: summary = self.manager.get_developer_revenue_summary(self.created_ids['developer'][0]) - self.log(f"Revenue summary for developer:") + self.log("Revenue summary for developer:") self.log(f" - Total sales: {summary['total_sales']}") self.log(f" - Total fees: {summary['total_fees']}") self.log(f" - Total earnings: {summary['total_earnings']}") diff --git a/backend/test_phase8_task8.py b/backend/test_phase8_task8.py index 323ba7b..1237bee 100644 --- a/backend/test_phase8_task8.py +++ b/backend/test_phase8_task8.py @@ -521,7 +521,7 @@ class TestOpsManager: self.manager.update_failover_status(event.id, "completed") updated_event = self.manager.get_failover_event(event.id) assert updated_event.status == "completed" - self.log(f"Failover completed") + self.log("Failover completed") # 获取故障转移事件列表 events = self.manager.list_failover_events(self.tenant_id) diff --git a/backend/tingwu_client.py b/backend/tingwu_client.py index 72b8fab..44c4b91 100644 --- a/backend/tingwu_client.py +++ b/backend/tingwu_client.py @@ -34,24 +34,6 @@ class TingwuClient: def create_task(self, audio_url: str, language: str = "zh") -> str: """创建听悟任务""" - endpoint = f"{self.endpoint}/openapi/tingwu/v2/tasks" - - payload = { - "Input": { - "Source": "OSS", - "FileUrl": audio_url - }, - "Parameters": { - "Transcription": { - "DiarizationEnabled": True, - "SentenceMaxLength": 20 - } - } - } - - # 使用阿里云 SDK 方式调用 (endpoint 和 payload 供后续扩展使用) - _ = endpoint - _ = payload try: from alibabacloud_tingwu20230930 import models as tingwu_models from alibabacloud_tingwu20230930.client import Client as TingwuSDKClient diff --git a/backend/workflow_manager.py b/backend/workflow_manager.py index e922709..a1ba454 100644 --- a/backend/workflow_manager.py +++ b/backend/workflow_manager.py @@ -1128,9 +1128,6 @@ class WorkflowManager: results = {} completed_tasks = set() - # 构建任务映射 (保留供调试使用) - _ = {t.id: t for t in tasks} - while len(completed_tasks) < len(tasks): # 找到可以执行的任务(依赖已完成) ready_tasks = [ @@ -1310,7 +1307,7 @@ class WorkflowManager: if webhook.template: try: message = json.loads(webhook.template.format(**input_data)) - except BaseException: + except (json.JSONDecodeError, KeyError, ValueError): pass success = await self.notifier.send(webhook, message)