"""Configuration for the NoteGraph ingestion service.""" from pathlib import Path from pydantic_settings import BaseSettings class IngestionConfig(BaseSettings): """All configuration loaded from environment variables / .env file.""" # LLM Provider llm_provider: str = "openai" llm_model: str = "gpt-4o" openai_api_key: str = "" anthropic_api_key: str = "" google_api_key: str = "" mistral_api_key: str = "" ollama_base_url: str = "http://localhost:11434" # OrgMyLife Integration orgmylife_api_url: str = "https://api.andreknie.de" orgmylife_api_key: str = "" # Nextcloud Inbox nextcloud_inbox_url: str = "" nextcloud_inbox_user: str = "" nextcloud_inbox_password: str = "" # Paths notes_dir: str = "./notes" inbox_dir: str = "./ingestion/inbox" # OCR ocr_enabled: bool = True ocr_language: str = "deu+eng" # Behavior confidence_threshold: float = 0.7 auto_commit: bool = True # Web Upload Auth (same as SilverBullet) sb_user: str = "admin:changeme" model_config = {"env_file": ".env", "env_prefix": "", "extra": "ignore"} @property def llm_model_string(self) -> str: """LiteLLM model string (e.g., 'openai/gpt-4o', 'ollama/llama3').""" if self.llm_provider == "ollama": return f"ollama/{self.llm_model}" return f"{self.llm_provider}/{self.llm_model}" def validate_api_key(self) -> None: """Exit with a clear error if the required API key is missing.""" key_map = { "openai": ("openai_api_key", "OPENAI_API_KEY"), "anthropic": ("anthropic_api_key", "ANTHROPIC_API_KEY"), "google": ("google_api_key", "GOOGLE_API_KEY"), "mistral": ("mistral_api_key", "MISTRAL_API_KEY"), } if self.llm_provider in key_map: attr, env_name = key_map[self.llm_provider] if not getattr(self, attr): raise SystemExit( f"ERROR: {env_name} is required for provider '{self.llm_provider}' but not set." )