A Simple and Universal Swarm Intelligence Engine, Predicting Anything. 简洁通用的群体智能引擎,预测万物
Python agent-memoryfinancial-forecastingfuture-predictionknowledge-graphllmsmulti-agent-simulationpublic-opinion-analysispython3social-predictionswarm-intelligence
refactor: add type hints and FileParser.is_supported() helper
lllopicdaec4b6be458
diff --git a/backend/app/config.py b/backend/app/config.pyindex 953dfa50..de63e2b4 100644--- a/backend/app/config.py+++ b/backend/app/config.py@@ -64,9 +64,9 @@ class Config:REPORT_AGENT_TEMPERATURE = float(os.environ.get('REPORT_AGENT_TEMPERATURE', '0.5'))@classmethod- def validate(cls):+ def validate(cls) -> list[str]:"""验证必要配置"""- errors = []+ errors: list[str] = []if not cls.LLM_API_KEY:errors.append("LLM_API_KEY 未配置")if not cls.ZEP_API_KEY:diff --git a/backend/app/utils/file_parser.py b/backend/app/utils/file_parser.pyindex 3f1d8ed2..5e540434 100644--- a/backend/app/utils/file_parser.py+++ b/backend/app/utils/file_parser.py@@ -63,6 +63,20 @@ class FileParser:SUPPORTED_EXTENSIONS = {'.pdf', '.md', '.markdown', '.txt'}+ @classmethod+ def is_supported(cls, file_path: str) -> bool:+ """+ 检查文件是否为支持的格式++ Args:+ file_path: 文件路径++ Returns:+ 如果文件格式受支持则返回 True+ """+ suffix = Path(file_path).suffix.lower()+ return suffix in cls.SUPPORTED_EXTENSIONS+@classmethoddef extract_text(cls, file_path: str) -> str:"""diff --git a/backend/app/utils/logger.py b/backend/app/utils/logger.pyindex 1978c0b8..93422afa 100644--- a/backend/app/utils/logger.py+++ b/backend/app/utils/logger.py@@ -109,18 +109,18 @@ logger = setup_logger()# 便捷方法-def debug(msg, *args, **kwargs):+def debug(msg: str, *args, **kwargs) -> None:logger.debug(msg, *args, **kwargs)-def info(msg, *args, **kwargs):+def info(msg: str, *args, **kwargs) -> None:logger.info(msg, *args, **kwargs)-def warning(msg, *args, **kwargs):+def warning(msg: str, *args, **kwargs) -> None:logger.warning(msg, *args, **kwargs)-def error(msg, *args, **kwargs):+def error(msg: str, *args, **kwargs) -> None:logger.error(msg, *args, **kwargs)-def critical(msg, *args, **kwargs):+def critical(msg: str, *args, **kwargs) -> None:logger.critical(msg, *args, **kwargs)