| """ |
| ByteAstra backend — application settings. |
| All values are loaded from environment variables (or .env file via python-dotenv). |
| """ |
| from pydantic_settings import BaseSettings, SettingsConfigDict |
| from functools import lru_cache |
|
|
|
|
| class Settings(BaseSettings): |
| model_config = SettingsConfigDict( |
| env_file=".env", |
| env_file_encoding="utf-8", |
| case_sensitive=False, |
| extra="ignore", |
| ) |
|
|
| |
| app_env: str = "development" |
| app_host: str = "0.0.0.0" |
| app_port: int = 8000 |
| app_secret_key: str = "change-me" |
|
|
| |
| database_url: str = "sqlite:///./byteastra.db" |
| mongo_url: str = "mongodb://localhost:27017" |
|
|
| |
| chroma_persist_path: str = "./chroma_store" |
|
|
| |
| |
| llm_base_url: str = "http://127.0.0.1:8001/v1" |
| openai_base_url: str | None = None |
| llm_api_key: str = "not-needed" |
| |
| llm_model_name: str = "qwen2.5-3b-instruct.Q4_K_M.gguf" |
| model_name: str | None = None |
| llm_max_tokens: int = 400 |
| llm_temperature: float = 0.2 |
|
|
| @property |
| def resolved_llm_base_url(self) -> str: |
| """Returns OPENAI_BASE_URL if set by start.sh, else llm_base_url.""" |
| return self.openai_base_url or self.llm_base_url |
|
|
| @property |
| def resolved_model_name(self) -> str: |
| """Returns MODEL_NAME if set by start.sh, else llm_model_name.""" |
| return self.model_name or self.llm_model_name |
|
|
| |
| embedding_model: str = "all-MiniLM-L6-v2" |
|
|
| |
| cors_origins: str = "http://localhost:3000,http://127.0.0.1:3000,http://localhost:7860,http://127.0.0.1:7860,https://byteastra-psi.vercel.app,https://byteastra.vercel.app" |
|
|
| @property |
| def cors_origins_list(self) -> list[str]: |
| return [o.strip() for o in self.cors_origins.split(",")] |
|
|
|
|
| @lru_cache |
| def get_settings() -> Settings: |
| return Settings() |
|
|