Spaces:
Runtime error
Runtime error
Commit ·
2c28073
1
Parent(s): 4f255eb
feat(config): read settings from env with no secret defaults
Browse files- app/config.py +32 -0
app/config.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pydantic_settings import BaseSettings, SettingsConfigDict
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class Settings(BaseSettings):
|
| 5 |
+
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
|
| 6 |
+
|
| 7 |
+
# Secrets — no defaults. Missing -> startup fails, naming the variable.
|
| 8 |
+
DATABASE_URL: str
|
| 9 |
+
JWT_SECRET_KEY: str
|
| 10 |
+
GEMINI_API_KEY: str
|
| 11 |
+
|
| 12 |
+
# Non-secret config — sensible defaults are fine.
|
| 13 |
+
GEMINI_MODEL: str = "gemini-flash-latest"
|
| 14 |
+
GEMINI_EMBEDDING_MODEL: str = "gemini-embedding-2"
|
| 15 |
+
EMBEDDING_DIM: int = 768
|
| 16 |
+
CHUNK_SIZE_TOKENS: int = 500
|
| 17 |
+
CHUNK_OVERLAP_TOKENS: int = 50
|
| 18 |
+
INLINE_SYNC_MAX_CHARS: int = 20000
|
| 19 |
+
RAG_TOP_K: int = 5
|
| 20 |
+
RAG_MIN_SIMILARITY: float = 0.55
|
| 21 |
+
RAG_FAITHFULNESS_MIN: float = 0.70
|
| 22 |
+
RAG_RELEVANCY_MIN: float = 0.70
|
| 23 |
+
CORS_ORIGINS: str = ""
|
| 24 |
+
ENVIRONMENT: str = "development"
|
| 25 |
+
|
| 26 |
+
@property
|
| 27 |
+
def cors_origins_list(self) -> list[str]:
|
| 28 |
+
return [o.strip() for o in self.CORS_ORIGINS.split(",") if o.strip()]
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
settings = Settings()
|
| 32 |
+
|