HipcallTts.Config (hipcall_tts v0.5.0)
View SourceConfiguration helper module for HipcallTts.
This module provides functions to read and resolve configuration values from application environment, with support for:
- Reading from application env
- Runtime overrides
- System environment variable resolution via
{:system, "ENV_VAR"}tuples - Graceful handling of missing configuration
Examples
# In config/config.exs:
config :hipcall_tts, :providers,
openai: [
api_key: {:system, "OPENAI_API_KEY"},
base_url: "https://api.openai.com"
]
# Usage:
config = HipcallTts.Config.get_provider_config(:openai)
# => [api_key: "actual-key-value", base_url: "https://api.openai.com"]
# With runtime overrides:
config = HipcallTts.Config.get_provider_config(:openai, api_key: "override-key")
# => [api_key: "override-key", base_url: "https://api.openai.com"]
Summary
Functions
Gets the configuration for a specific provider.
Resolves system environment variables in a configuration keyword list.
Functions
Gets the configuration for a specific provider.
Reads the provider configuration from application environment, resolves system environment variables, and merges with any runtime overrides.
Parameters
provider- The atom identifier for the provider (e.g.,:openai,:aws_polly)opts- Optional keyword list of runtime overrides that will be merged into the configuration (default:[])
Returns
A keyword list containing the resolved provider configuration.
Examples
# Basic usage
config = HipcallTts.Config.get_provider_config(:openai)
# With runtime overrides
config = HipcallTts.Config.get_provider_config(:openai, api_key: "custom-key")
# Missing provider returns empty list
config = HipcallTts.Config.get_provider_config(:nonexistent)
# => []
Resolves system environment variables in a configuration keyword list.
Recursively processes the configuration and replaces {:system, "ENV_VAR"}
tuples with the actual environment variable value. If the environment
variable is not set, it raises an error.
Also handles nested keyword lists and maps.
Parameters
config- A keyword list or map containing configuration values
Returns
A keyword list or map with all {:system, "ENV_VAR"} tuples resolved
to their actual values.
Examples
config = [api_key: {:system, "API_KEY"}, timeout: 5000]
resolved = HipcallTts.Config.resolve_system_vars(config)
# => [api_key: "actual-env-value", timeout: 5000]
# Handles nested structures
config = [
provider: [
api_key: {:system, "API_KEY"},
options: %{base_url: {:system, "BASE_URL"}}
]
]
resolved = HipcallTts.Config.resolve_system_vars(config)