feat: 提交热榜评论分析工具 MVP 基线
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
from functools import lru_cache
|
||||
|
||||
from pydantic import field_validator
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")
|
||||
|
||||
app_env: str = "development"
|
||||
database_url: str = "sqlite:///data/app.db"
|
||||
tikhub_api_key: str = ""
|
||||
tikhub_base_url: str = "https://api.tikhub.io"
|
||||
ai_provider: str = "openai-compatible"
|
||||
ai_base_url: str = ""
|
||||
ai_api_key: str = ""
|
||||
ai_model: str = ""
|
||||
ai_batch_size: int = 20
|
||||
ai_concurrency: int = 2
|
||||
ai_max_retries: int = 3
|
||||
ai_timeout_seconds: int = 30
|
||||
http_timeout_seconds: int = 20
|
||||
http_max_retries: int = 3
|
||||
crawl_page_interval_seconds: float = 1.5
|
||||
|
||||
hot_limit_min: int = 1
|
||||
hot_limit_max: int = 10
|
||||
item_limit_per_hot_min: int = 1
|
||||
item_limit_per_hot_max: int = 10
|
||||
comment_limit_per_item_min: int = 10
|
||||
comment_limit_per_item_max: int = 100
|
||||
|
||||
@field_validator("ai_concurrency", mode="after")
|
||||
@classmethod
|
||||
def cap_ai_concurrency(cls, value: int) -> int:
|
||||
return min(value, 3)
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_settings() -> Settings:
|
||||
return Settings()
|
||||
Reference in New Issue
Block a user