40 lines
991 B
Python
40 lines
991 B
Python
from typing import Literal
|
|
|
|
from pydantic_settings import BaseSettings
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Application configuration loaded from environment variables."""
|
|
|
|
llm_mode: Literal["local", "remote", "openai", "asksage"] = "local"
|
|
llm_remote_url: str = ""
|
|
llm_remote_token: str = ""
|
|
|
|
# OpenAI configuration
|
|
openai_api_key: str = ""
|
|
openai_model: str = "gpt-4o-mini"
|
|
|
|
# AskSage configuration
|
|
asksage_email: str = ""
|
|
asksage_api_key: str = ""
|
|
asksage_model: str = "gpt-4o"
|
|
|
|
# CORS configuration
|
|
cors_origins: str = "http://localhost:3000"
|
|
|
|
@property
|
|
def cors_origins_list(self) -> list[str]:
|
|
"""Parse comma-separated CORS origins into a list."""
|
|
return [origin.strip() for origin in self.cors_origins.split(",") if origin.strip()]
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
env_file_encoding = "utf-8"
|
|
|
|
|
|
# Constants
|
|
MAX_MESSAGE_LENGTH: int = 10_000
|
|
|
|
# Global settings instance
|
|
settings = Settings()
|