from __future__ import annotations from functools import lru_cache from pathlib import Path from pydantic import Field from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): model_config = SettingsConfigDict(env_file=".env", extra="ignore") app_name: str = "vsf-duoc-thu-ai-service" qdrant_url: str = "http://localhost:6333" qdrant_collection: str = "duocthu_v1" qdrant_api_key: str | None = None postgres_dsn: str = Field( default="postgresql://duoc_thu:duoc_thu@localhost:5432/duoc_thu", repr=False, ) # `cohere-v4` = semantic query embedding in the corpus's own space (requires # live Bedrock). `disabled` skips retrieval entirely. The old local-hash / # section-only stub embedders were removed in the 2026-08-06 rebuild. embedding_provider: str = "cohere-v4" embedding_dimensions: int = 1024 evidence_minimum_score: float = 0.12 aws_region: str = "us-east-1" # Generation is off unless asked for. `stub` runs the whole answer path — # prompt, schema parsing, grounding check, fallback — with no cloud call. # Live options: `bedrock-converse` (DeepSeek/Qwen/GLM/Nova via the Converse # API) or `bedrock-claude` (Anthropic via the Messages path). answer_provider: str = "disabled" answer_model_id: str = "deepseek.v3.2" # Optional cross-encoder rerank on the similarity fallback (needs live # Bedrock invoke on the rerank model). Off by default; the section route # never uses it. rerank_enabled: bool = False metrics_enabled: bool = True entities_path: Path = ( Path(__file__).resolve().parents[2] / "ingestion/data/verified/drug_entities.json" ) @lru_cache def get_settings() -> Settings: return Settings()