ativa-ia/rag-api/config.py

36 lines
1.2 KiB
Python

"""Canonical defaults and environment parsing for the RAG API runtime."""
from __future__ import annotations
import os
from dataclasses import dataclass
@dataclass(frozen=True)
class Settings:
qdrant_url: str
ollama_url: str
collection: str
embed_model: str
chat_model: str
api_key: str
score_threshold: float
max_context_chars: int
max_question_chars: int
@classmethod
def from_environment(cls) -> "Settings":
return cls(
qdrant_url=os.getenv("QDRANT_URL", "http://192.168.0.153:6333").rstrip("/"),
ollama_url=os.getenv("OLLAMA_URL", "http://192.168.0.106:11434").rstrip("/"),
collection=os.getenv("QDRANT_COLLECTION", "ativa_knowledge"),
embed_model=os.getenv("EMBED_MODEL", "nomic-embed-text"),
chat_model=os.getenv("CHAT_MODEL", "ativa-assistente"),
api_key=os.getenv("ATIVA_RAG_API_KEY", "").strip(),
score_threshold=float(os.getenv("RAG_SCORE_THRESHOLD", "0.55")),
max_context_chars=int(os.getenv("RAG_MAX_CONTEXT_CHARS", "18000")),
max_question_chars=int(os.getenv("RAG_MAX_QUESTION_CHARS", "2000")),
)
settings = Settings.from_environment()