| from pydantic_settings import BaseSettings, SettingsConfigDict
|
| from typing import List, Optional
|
|
|
| class Settings(BaseSettings):
|
|
|
| QDRANT_URL: str = "http://localhost:6333"
|
| DEFAULT_COLLECTION: str = "sample_docs"
|
|
|
|
|
| ALLOW_MODELS: str = "all"
|
|
|
|
|
| API_KEY: Optional[str] = None
|
| CORS_ALLOW_ORIGINS: str = "*"
|
|
|
| model_config = SettingsConfigDict(env_file=".env", extra="ignore")
|
|
|
| @property
|
| def allow_models(self) -> List[tuple]:
|
|
|
| if self.ALLOW_MODELS.strip().lower() == "all":
|
| from .embeddings_registry import PRESETS
|
| return [(spec["backend"], spec["name"]) for spec in PRESETS.values()]
|
|
|
|
|
| items = []
|
| for token in self.ALLOW_MODELS.split(","):
|
| token = token.strip()
|
| if not token:
|
| continue
|
| if ":" not in token:
|
| continue
|
| backend, name = token.split(":", 1)
|
| items.append((backend.strip(), name.strip()))
|
| return items
|
|
|
| settings = Settings()
|
|
|