diff --git a/untitledai/core/cli.py b/untitledai/core/cli.py index f9898924..e0174418 100644 --- a/untitledai/core/cli.py +++ b/untitledai/core/cli.py @@ -13,7 +13,6 @@ import click from rich.console import Console -from pydantic_yaml import parse_yaml_raw_as from ..services.stt.asynchronous.async_transcription_service_factory import AsyncTranscriptionServiceFactory from ..services.conversation.transcript_summarizer import TranscriptionSummarizer @@ -28,7 +27,7 @@ #################################################################################################### def load_config_yaml(ctx, param, value) -> Configuration: - return parse_yaml_raw_as(Configuration, value) + return Configuration.load_config_yaml(value.name) def add_options(options): def _add_options(func): diff --git a/untitledai/core/config.py b/untitledai/core/config.py index b32936bb..c578a1dd 100644 --- a/untitledai/core/config.py +++ b/untitledai/core/config.py @@ -1,4 +1,6 @@ from pydantic import BaseModel +import yaml +import os from typing import Optional class TranscriptionConfiguration(BaseModel): @@ -46,6 +48,25 @@ class NotificationConfiguration(BaseModel): apn_team_id: str | None class Configuration(BaseModel): + + @classmethod + def load_config_yaml(cls, config_file_path: str) -> 'Configuration': + """ + Load configuration from YAML file and apply environment variable overrides. + """ + with open(config_file_path, 'r') as stream: + config_data = yaml.safe_load(stream) + + # Apply environment variable overrides + for section, section_config in config_data.items(): + for key, val in section_config.items(): + env_var = os.environ.get(f"UNTITLEDAI_{section.upper()}_{key.upper()}") + if env_var: + config_data[section][key] = env_var + + return cls(**config_data) + + transcription: TranscriptionConfiguration llm: LLMConfiguration captures: CapturesConfiguration