Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def broadcast(self, message: str):
for connection in self.active_connections:
try:
await connection.send_text(message)
except:
except Exception:
# 连接已断开,移除
self.active_connections.remove(connection)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def _convert_parameter_types(self, tool_name: str, param_dict: dict) -> dict:
# 获取工具的参数定义
try:
tool_params = tool.get_parameters()
except:
except Exception:
return param_dict

# 创建参数类型映射
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,5 +451,5 @@ def __del__(self):
if hasattr(self, 'driver') and self.driver:
try:
self.driver.close()
except:
except Exception:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -538,5 +538,5 @@ def __del__(self):
if hasattr(self, 'client') and self.client:
try:
self.client.close()
except:
except Exception:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def _extract_entities(self, text: str) -> List[Entity]:
try:
if hasattr(ent._, 'confidence'):
confidence = getattr(ent._, 'confidence', 'N/A')
except:
except Exception:
confidence = "N/A"

logger.debug(f"🏷️ spaCy识别实体: '{ent.text}' -> {ent.label_} (置信度: {confidence})")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def _markdown_to_note(self, markdown_text: str) -> Dict[str, Any]:
if key == 'tags':
try:
note[key] = json.loads(value)
except:
except Exception:
note[key] = []
else:
note[key] = value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def _extract_evaluation(self, text: str) -> Dict[str, any]:
try:
# 尝试直接解析
return json.loads(text)
except:
except Exception:
# 失败则返回默认值
return {
"score": 0.5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ def create_simple_rating_groups(rating):
'significant': p_value_prev < 0.05
}
}
except:
except Exception:
correlation_results = {'error': '相关性计算失败'}

# 4. 核心结果:关键指标对比
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def get_content_from_note(self, content: str) -> str:
content = '\n'.join(lines[1:]).strip()

return content
except:
except Exception:
return content

def get_memories(self, novel_id: str):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ def show_reminder(self):
if not PIL_AVAILABLE:
try:
messagebox.showerror("错误", "Pillow 未安装,无法显示图片\n请运行: pip install Pillow")
except:
except Exception:
print("❌ 错误: Pillow 未安装,无法显示图片\n💡 请运行: pip install Pillow")
return

if not self.load_image():
try:
messagebox.showerror("错误", "未找到人物图片文件\n请将图片放在 assets/ 目录下\n支持的名称: person.png, person.jpg, reminder.png")
except:
except Exception:
print("❌ 错误: 未找到人物图片文件\n💡 请将图片放在 assets/ 目录下")
return

Expand Down Expand Up @@ -188,7 +188,7 @@ def fade_out():
try:
self.window.attributes('-alpha', alpha)
self.window.after(30, fade_out)
except:
except Exception:
pass
else:
if self.window:
Expand All @@ -203,7 +203,7 @@ def start_write_report(self):
error_msg = f"未找到 write_report.py\n路径: {write_report_script}"
try:
messagebox.showerror("错误", error_msg)
except:
except Exception:
print(f"❌ {error_msg}")
return

Expand All @@ -218,7 +218,7 @@ def start_write_report(self):
error_msg = f"启动写日报失败: {e}"
try:
messagebox.showerror("错误", error_msg)
except:
except Exception:
print(f"❌ {error_msg}")

def show_system_notification(self):
Expand All @@ -230,7 +230,7 @@ def show_system_notification(self):
message="该写日报啦!点击通知打开写日报。",
timeout=10
)
except:
except Exception:
print("📝 写日报提醒:该写日报啦!")


Expand Down
2 changes: 1 addition & 1 deletion Co-creation-projects/melxy1997-ColumnWriter/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _export_report(column_data: Dict[str, Any], filepath: str):
try:
start_time = datetime.fromisoformat(start_time)
end_time = datetime.fromisoformat(end_time)
except:
except Exception:
pass

if isinstance(start_time, datetime) and isinstance(end_time, datetime):
Expand Down
2 changes: 1 addition & 1 deletion Co-creation-projects/melxy1997-ColumnWriter/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def _extract_from_braces(response: str) -> Optional[Dict[str, Any]]:
parsed = JSONExtractor._parse_json_with_retry(json_str)
if isinstance(parsed, dict):
json_candidates.append((parsed, len(parsed)))
except:
except Exception:
pass
i = brace_end
else:
Expand Down
2 changes: 1 addition & 1 deletion Co-creation-projects/pamdla-MindEchoAgent/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def extract_music_info(response_text):
"mood": data.get("mood", ""),
"full_data": data
}
except:
except Exception:
pass

# 如果没有找到音乐数据,返回默认信息
Expand Down
2 changes: 1 addition & 1 deletion code/chapter10/09_A2A_Network.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def write_article(text: str) -> str:
data = eval(content)
topic = data.get("topic", "未知主题")
findings = data.get("findings", "无研究结果")
except:
except Exception:
topic = "未知主题"
findings = content

Expand Down
2 changes: 1 addition & 1 deletion code/chapter10/10_AgentNegotiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def handle_proposal(text: str) -> str:
"counter_proposal": {"deadline": 7}
}
return str(result)
except:
except Exception:
return str({"accepted": False, "message": "无效的提案格式"})

agent2 = A2AServer(
Expand Down
2 changes: 1 addition & 1 deletion code/chapter12/data_generation/aime_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __init__(
# 尝试不同的split
try:
dataset = load_dataset(reference_dataset, split="train")
except:
except Exception:
dataset = load_dataset(reference_dataset, split="test")

# 加载所有题目作为参考
Expand Down
2 changes: 1 addition & 1 deletion code/chapter15/Helloagents-AI-Town/backend/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def clear_npc_memory(self, npc_name: str, memory_type: Optional[str] = None):
for mem_type in ["working", "episodic"]:
try:
memory_manager.clear_memory_type(mem_type)
except:
except Exception:
pass
print(f"✅ 已清空{npc_name}的所有记忆")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def _parse_response(self, response: str) -> Optional[Dict[str, str]]:

if isinstance(dialogues, dict):
return dialogues
except:
except Exception:
pass

print(f"⚠️ 无法解析响应: {response[:100]}...")
Expand Down
2 changes: 1 addition & 1 deletion code/chapter7/my_calculator_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def my_calculate(expression: str) -> str:
node = ast.parse(expression, mode='eval')
result = _eval_node(node.body, operators, functions)
return str(result)
except:
except Exception:
return "计算失败,请检查表达式格式"

def _eval_node(node, operators, functions):
Expand Down
2 changes: 1 addition & 1 deletion code/chapter9/codebase_maintainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def get_stats(self) -> Dict[str, Any]:
# 获取笔记摘要
try:
note_summary = self.note_tool.run({"action": "summary"})
except:
except Exception:
note_summary = {}

return {
Expand Down