26 lines
705 B
Python
26 lines
705 B
Python
from functools import lru_cache
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""集中管理项目配置,来源于 .env / 环境变量。"""
|
|
|
|
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")
|
|
|
|
supabase_url: str
|
|
supabase_service_role_key: str
|
|
redis_url: str = "redis://localhost:6379/0"
|
|
frontend_url: str = "http://localhost:3000"
|
|
openai_api_key: str = ""
|
|
lightrag_db_url: str
|
|
lightrag_collection: str = "wolai-docs"
|
|
|
|
|
|
@lru_cache
|
|
def get_settings() -> Settings:
|
|
"""惰性实例化设置,避免重复读取文件。"""
|
|
return Settings()
|
|
|
|
|
|
settings = get_settings()
|