Class: LlmConductor::Configuration
- Inherits:
-
Object
- Object
- LlmConductor::Configuration
- Defined in:
- lib/llm_conductor/configuration.rb
Overview
Configuration class for managing API keys, endpoints, and default settings
Instance Attribute Summary collapse
-
#default_model ⇒ Object
Returns the value of attribute default_model.
-
#default_vendor ⇒ Object
Returns the value of attribute default_vendor.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_retries ⇒ Object
Returns the value of attribute max_retries.
-
#providers ⇒ Object
readonly
Returns the value of attribute providers.
-
#retry_delay ⇒ Object
Returns the value of attribute retry_delay.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#anthropic(api_key: nil, **options) ⇒ Object
Configure Anthropic provider.
-
#anthropic_api_key ⇒ Object
Legacy compatibility methods.
- #anthropic_api_key=(value) ⇒ Object
-
#gemini(api_key: nil, project_id: nil, region: nil, file_path: nil, file_contents: nil, **options) ⇒ Object
Configure Google Gemini provider (Generative Language API or Vertex AI).
- #gemini_api_key ⇒ Object
- #gemini_api_key=(value) ⇒ Object
-
#groq(api_key: nil, **options) ⇒ Object
Configure Groq provider.
- #groq_api_key ⇒ Object
- #groq_api_key=(value) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#ollama(base_url: nil, **options) ⇒ Object
Configure Ollama provider.
- #ollama_address ⇒ Object
- #ollama_address=(value) ⇒ Object
-
#openai(api_key: nil, organization: nil, **options) ⇒ Object
Configure OpenAI provider.
- #openai_api_key ⇒ Object
- #openai_api_key=(value) ⇒ Object
-
#openrouter(api_key: nil, **options) ⇒ Object
Configure OpenRouter provider.
- #openrouter_api_key ⇒ Object
- #openrouter_api_key=(value) ⇒ Object
-
#provider_config(provider) ⇒ Object
Get provider configuration.
-
#zai(api_key: nil, **options) ⇒ Object
Configure Z.ai provider.
- #zai_api_key ⇒ Object
- #zai_api_key=(value) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/llm_conductor/configuration.rb', line 10 def initialize # Default settings @default_model = 'gpt-5-mini' @default_vendor = :openai @timeout = 30 # Retry policy for transient provider failures, applied to every client by # LlmConductor::Clients::Concerns::Retryable. max_retries is a TOTAL attempt # budget including the first call (3 = one call plus at most two retries); # retry_delay seeds the exponential backoff. See docs/retries.md. @max_retries = 3 @retry_delay = 1.0 @logger = nil # Provider configurations @providers = {} # Initialize with environment variables if available setup_defaults_from_env end |
Instance Attribute Details
#default_model ⇒ Object
Returns the value of attribute default_model.
7 8 9 |
# File 'lib/llm_conductor/configuration.rb', line 7 def default_model @default_model end |
#default_vendor ⇒ Object
Returns the value of attribute default_vendor.
7 8 9 |
# File 'lib/llm_conductor/configuration.rb', line 7 def default_vendor @default_vendor end |
#logger ⇒ Object
Returns the value of attribute logger.
7 8 9 |
# File 'lib/llm_conductor/configuration.rb', line 7 def logger @logger end |
#max_retries ⇒ Object
Returns the value of attribute max_retries.
7 8 9 |
# File 'lib/llm_conductor/configuration.rb', line 7 def max_retries @max_retries end |
#providers ⇒ Object (readonly)
Returns the value of attribute providers.
8 9 10 |
# File 'lib/llm_conductor/configuration.rb', line 8 def providers @providers end |
#retry_delay ⇒ Object
Returns the value of attribute retry_delay.
7 8 9 |
# File 'lib/llm_conductor/configuration.rb', line 7 def retry_delay @retry_delay end |
#timeout ⇒ Object
Returns the value of attribute timeout.
7 8 9 |
# File 'lib/llm_conductor/configuration.rb', line 7 def timeout @timeout end |
Instance Method Details
#anthropic(api_key: nil, **options) ⇒ Object
Configure Anthropic provider
31 32 33 34 35 36 |
# File 'lib/llm_conductor/configuration.rb', line 31 def anthropic(api_key: nil, **) @providers[:anthropic] = { api_key: api_key || ENV['ANTHROPIC_API_KEY'], ** } end |
#anthropic_api_key ⇒ Object
Legacy compatibility methods
104 105 106 |
# File 'lib/llm_conductor/configuration.rb', line 104 def anthropic_api_key provider_config(:anthropic)[:api_key] end |
#anthropic_api_key=(value) ⇒ Object
108 109 110 |
# File 'lib/llm_conductor/configuration.rb', line 108 def anthropic_api_key=(value) anthropic(api_key: value) end |
#gemini(api_key: nil, project_id: nil, region: nil, file_path: nil, file_contents: nil, **options) ⇒ Object
Configure Google Gemini provider (Generative Language API or Vertex AI)
For the standard Generative Language API, provide api_key. For Vertex AI, provide project_id and optionally region (defaults to 'global'). Authentication falls back to Application Default Credentials (ADC / GOOGLE_APPLICATION_CREDENTIALS) when neither file_path nor file_contents is supplied. Env vars (GEMINI_API_KEY, GOOGLE_VERTEX_PROJECT_ID, etc.) are only applied automatically on boot via setup_defaults_from_env — explicit calls use only what is passed.
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/llm_conductor/configuration.rb', line 71 def gemini(api_key: nil, project_id: nil, region: nil, file_path: nil, file_contents: nil, **) @providers[:gemini] = { api_key:, project_id:, region: region || 'global', file_path:, file_contents:, ** }.compact end |
#gemini_api_key ⇒ Object
136 137 138 |
# File 'lib/llm_conductor/configuration.rb', line 136 def gemini_api_key provider_config(:gemini)[:api_key] end |
#gemini_api_key=(value) ⇒ Object
140 141 142 |
# File 'lib/llm_conductor/configuration.rb', line 140 def gemini_api_key=(value) gemini(api_key: value) end |
#groq(api_key: nil, **options) ⇒ Object
Configure Groq provider
83 84 85 86 87 88 |
# File 'lib/llm_conductor/configuration.rb', line 83 def groq(api_key: nil, **) @providers[:groq] = { api_key: api_key || ENV['GROQ_API_KEY'], ** } end |
#groq_api_key ⇒ Object
144 145 146 |
# File 'lib/llm_conductor/configuration.rb', line 144 def groq_api_key provider_config(:groq)[:api_key] end |
#groq_api_key=(value) ⇒ Object
148 149 150 |
# File 'lib/llm_conductor/configuration.rb', line 148 def groq_api_key=(value) groq(api_key: value) end |
#ollama(base_url: nil, **options) ⇒ Object
Configure Ollama provider
48 49 50 51 52 53 |
# File 'lib/llm_conductor/configuration.rb', line 48 def ollama(base_url: nil, **) @providers[:ollama] = { base_url: base_url || ENV['OLLAMA_ADDRESS'] || 'http://localhost:11434', ** } end |
#ollama_address ⇒ Object
128 129 130 |
# File 'lib/llm_conductor/configuration.rb', line 128 def ollama_address provider_config(:ollama)[:base_url] end |
#ollama_address=(value) ⇒ Object
132 133 134 |
# File 'lib/llm_conductor/configuration.rb', line 132 def ollama_address=(value) ollama(base_url: value) end |
#openai(api_key: nil, organization: nil, **options) ⇒ Object
Configure OpenAI provider
39 40 41 42 43 44 45 |
# File 'lib/llm_conductor/configuration.rb', line 39 def openai(api_key: nil, organization: nil, **) @providers[:openai] = { api_key: api_key || ENV['OPENAI_API_KEY'], organization: organization || ENV['OPENAI_ORG_ID'], ** } end |
#openai_api_key ⇒ Object
112 113 114 |
# File 'lib/llm_conductor/configuration.rb', line 112 def openai_api_key provider_config(:openai)[:api_key] end |
#openai_api_key=(value) ⇒ Object
116 117 118 |
# File 'lib/llm_conductor/configuration.rb', line 116 def openai_api_key=(value) openai(api_key: value) end |
#openrouter(api_key: nil, **options) ⇒ Object
Configure OpenRouter provider
56 57 58 59 60 61 |
# File 'lib/llm_conductor/configuration.rb', line 56 def openrouter(api_key: nil, **) @providers[:openrouter] = { api_key: api_key || ENV['OPENROUTER_API_KEY'], ** } end |
#openrouter_api_key ⇒ Object
120 121 122 |
# File 'lib/llm_conductor/configuration.rb', line 120 def openrouter_api_key provider_config(:openrouter)[:api_key] end |
#openrouter_api_key=(value) ⇒ Object
124 125 126 |
# File 'lib/llm_conductor/configuration.rb', line 124 def openrouter_api_key=(value) openrouter(api_key: value) end |
#provider_config(provider) ⇒ Object
Get provider configuration
99 100 101 |
# File 'lib/llm_conductor/configuration.rb', line 99 def provider_config(provider) @providers[provider.to_sym] || {} end |
#zai(api_key: nil, **options) ⇒ Object
Configure Z.ai provider
91 92 93 94 95 96 |
# File 'lib/llm_conductor/configuration.rb', line 91 def zai(api_key: nil, **) @providers[:zai] = { api_key: api_key || ENV['ZAI_API_KEY'], ** } end |
#zai_api_key ⇒ Object
152 153 154 |
# File 'lib/llm_conductor/configuration.rb', line 152 def zai_api_key provider_config(:zai)[:api_key] end |
#zai_api_key=(value) ⇒ Object
156 157 158 |
# File 'lib/llm_conductor/configuration.rb', line 156 def zai_api_key=(value) zai(api_key: value) end |