from functools import lru_cache from pydantic import Field from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): app_env: str = "local" app_name: str = "jr-agent-platform" log_level: str = "INFO" timezone: str = "Asia/Shanghai" jwt_issuer: str jwt_audience: str jwt_algorithm: str = "RS256" jwt_private_key_path: str = "config/jwt/jwt-private.pem" jwt_public_key_path: str = "config/jwt/jwt-public.pem" jwt_clock_skew_seconds: int = Field(default=30, ge=0) mysql_dsn: str mysql_pool_size: int = Field(default=5, ge=1) mysql_max_overflow: int = Field(default=10, ge=0) mysql_pool_pre_ping: bool = False mysql_tx_isolation: str = "READ COMMITTED" redis_url: str redis_connect_timeout_seconds: float = Field(default=2, gt=0) message_broker_url: str = "" message_broker_run_topic: str = "agent.run" message_broker_outbox_topic: str = "agent.outbox" message_broker_dlq_topic: str = "agent.dlq" milvus_uri: str milvus_token: str = "" milvus_collection: str = "jr_memory" neo4j_uri: str neo4j_database: str = "neo4j" neo4j_username: str = "neo4j" neo4j_password: str = "" model_router_config_ref: str = "local" model_default_endpoint: str = "" model_fallback_endpoint: str = "" sse_heartbeat_seconds: int = Field(default=15, gt=0) sse_chunk_characters: int = Field(default=256, ge=1, le=4096) sse_max_connection_seconds: int = Field(default=300, gt=0) worker_lease_seconds: int = Field(default=60, gt=0) worker_retry_limit: int = Field(default=3, ge=0) worker_poll_seconds: float = Field(default=1, gt=0) offsite_mailbox: str = "15273589815@163.com" offsite_allowed_senders: tuple[str, ...] = ("15008108550@163.com",) offsite_risk_receiver_id: str = "" offsite_settlement_receiver_id: str = "" offsite_mail_return_receiver: str = "15008108550@163.com" offsite_max_retry_count: int = Field(default=3, ge=0) offsite_imap_enabled: bool = False offsite_imap_host: str = "" offsite_imap_port: int = Field(default=993, gt=0) offsite_imap_username: str = "" offsite_imap_password: str = "" offsite_imap_use_ssl: bool = True offsite_imap_idle_enabled: bool = False offsite_mail_worker_enabled: bool = False offsite_mail_worker_batch_size: int = Field(default=20, ge=1, le=100) offsite_worker_user_id: str = "" offsite_notification_sending_timeout_seconds: int = Field(default=900, gt=0) offsite_mail_storage_dir: str = "data/offsite_mail" offsite_ocr_enabled: bool = False offsite_ocr_timeout_seconds: float = Field(default=30, gt=0) offsite_aliyun_ocr_endpoint: str = "" offsite_aliyun_access_key_id: str = "" offsite_aliyun_access_key_secret: str = "" offsite_deepseek_enabled: bool = False offsite_deepseek_base_url: str = "https://api.deepseek.com" offsite_deepseek_api_key: str = "" offsite_deepseek_model: str = "deepseek-v4-flash" offsite_deepseek_timeout_seconds: float = Field(default=30, gt=0) offsite_smtp_enabled: bool = False offsite_smtp_dry_run: bool = True offsite_smtp_host: str = "" offsite_smtp_port: int = Field(default=465, gt=0) offsite_smtp_username: str = "" offsite_smtp_password: str = "" offsite_smtp_sender: str = "" offsite_smtp_use_ssl: bool = True offsite_smtp_timeout_seconds: float = Field(default=30, gt=0) model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore") @lru_cache(maxsize=1) def get_settings() -> Settings: return Settings() # type: ignore[call-arg]