""" Global configuration for Core Code API """ from pydantic_settings import BaseSettings from functools import lru_cache class Settings(BaseSettings): """Global application settings""" # Application app_name: str = "Core Code API" app_version: str = "1.0.0" debug: bool = False # Server host: str = "0.0.0.0" port: int = 8083 # CORS cors_origins: list[str] = ["*"] cors_credentials: bool = True cors_methods: list[str] = ["*"] cors_headers: list[str] = ["*"] # Logging log_level: str = "INFO" # Ollama Configuration (for AI orchestration) ollama_base_url: str = "http://ollama:11434" ollama_timeout: int = 300 # 5 minutes # Model Configuration default_model: str = "gemma:7b" lightweight_models: str = "gemma:2b,gemma:7b" heavy_models: str = "mistral:7b,gemma2:9b,mixtral:8x7b" code_models: str = "codestral:latest,codegemma:latest" # Model Aliases (OpenAI → Local) alias_gpt35: str = "gemma:7b" alias_gpt4: str = "mistral:7b" alias_gpt4_turbo: str = "mixtral:8x7b" alias_gpt4_code: str = "codestral:latest" # Memory Configuration memory_tier1_max_turns: int = 10 memory_consolidation_threshold: int = 10 # Qdrant Configuration qdrant_host: str = "qdrant" qdrant_port: int = 6333 qdrant_collection_conversations: str = "core_api_conversations" qdrant_collection_documents: str = "core_api_documents" qdrant_collection_user_facts: str = "core_api_user_facts" # Embeddings embedding_model: str = "sentence-transformers/all-MiniLM-L6-v2" embedding_dimension: int = 384 embedding_batch_size: int = 32 # Infrastructure Management portainer_url: str = "http://localhost:8001" portainer_api_key: str = "" npm_url: str = "http://localhost:81" npm_email: str = "" npm_password: str = "" kuma_url: str = "http://localhost:3001" kuma_username: str = "" kuma_password: str = "" @property def model_aliases(self) -> dict: """Computed property for model aliases""" return { "gpt-3.5-turbo": self.alias_gpt35, "gpt-4": self.alias_gpt4, "gpt-4-turbo": self.alias_gpt4_turbo, "gpt-4-code": self.alias_gpt4_code, } def get_lightweight_models(self) -> list[str]: """Parse comma-separated lightweight models""" return [m.strip().strip('"').strip("'") for m in self.lightweight_models.split(",") if m.strip()] def get_heavy_models(self) -> list[str]: """Parse comma-separated heavy models""" return [m.strip().strip('"').strip("'") for m in self.heavy_models.split(",") if m.strip()] def get_code_models(self) -> list[str]: """Parse comma-separated code models""" return [m.strip().strip('"').strip("'") for m in self.code_models.split(",") if m.strip()] class Config: env_file = ".env" case_sensitive = False @lru_cache() def get_settings() -> Settings: """Cached settings instance""" return Settings()