43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
from functools import lru_cache
|
|
from pathlib import Path
|
|
|
|
from pydantic import Field
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
# 配置统一来自环境变量,保证本地和服务器使用同一套启动路径。
|
|
app_name: str = "SignalScout"
|
|
env: str = "dev"
|
|
database_url: str = Field(
|
|
default="mysql+pymysql://signalscout:signalscout@127.0.0.1:3306/signalscout?charset=utf8mb4"
|
|
)
|
|
llm_base_url: str = "https://api.zayuapi.com/v1"
|
|
llm_api_key: str = ""
|
|
llm_model: str = "grok-4.3"
|
|
llm_timeout_seconds: int = 90
|
|
llm_max_tokens: int = 8000
|
|
news_recent_days: int = 3
|
|
news_max_items: int = 60
|
|
news_search_max_records: int = 100
|
|
github_recent_days: int = 30
|
|
github_min_stars: int = 20
|
|
github_max_projects: int = 40
|
|
agent_timezone: str = "Asia/Shanghai"
|
|
agent_interval_minutes: int = 30
|
|
report_dir: Path = Path("reports")
|
|
log_file: Path = Path("logs/app.log")
|
|
log_tail_lines: int = 200
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_prefix="SIGNALSCOUT_",
|
|
extra="ignore",
|
|
)
|
|
|
|
|
|
@lru_cache
|
|
def get_settings() -> Settings:
|
|
# Caching prevents repeated env parsing while tests can still clear it if needed.
|
|
return Settings()
|