Skip to content

Commit

Permalink
Allow environmental overrides for cloud deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
etown committed Feb 3, 2024
1 parent a52c274 commit ce3ec95
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
3 changes: 1 addition & 2 deletions untitledai/core/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
21 changes: 21 additions & 0 deletions untitledai/core/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from pydantic import BaseModel
import yaml
import os
from typing import Optional

class TranscriptionConfiguration(BaseModel):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ce3ec95

Please sign in to comment.