Ajout de la partie IA
This commit is contained in:
0
brain/app/core/__init__.py
Normal file
0
brain/app/core/__init__.py
Normal file
29
brain/app/core/config.py
Normal file
29
brain/app/core/config.py
Normal file
@@ -0,0 +1,29 @@
|
||||
"""Configuration applicative centralisée (principe 12-factor : config via env).
|
||||
|
||||
Équivalent Python du `application.properties` Spring Boot, avec validation
|
||||
Pydantic : une variable manquante/invalide = crash au démarrage, pas une
|
||||
NullPointerException surprise à la 3ème requête.
|
||||
"""
|
||||
from functools import lru_cache
|
||||
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""Settings chargés depuis .env ou variables d'environnement."""
|
||||
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=".env",
|
||||
env_file_encoding="utf-8",
|
||||
extra="ignore",
|
||||
)
|
||||
|
||||
ollama_base_url: str = "http://localhost:11434"
|
||||
llm_model: str = "gemma4:e2b"
|
||||
llm_timeout_seconds: int = 120
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_settings() -> Settings:
|
||||
"""Singleton via cache — FastAPI l'injecte avec Depends() dans les routes."""
|
||||
return Settings()
|
||||
Reference in New Issue
Block a user