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 |
# File 'lib/llm_conductor/configuration.rb', line 10 def initialize # Default settings @default_model = 'gpt-5-mini' @default_vendor = :openai @timeout = 30 @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
27 28 29 30 31 32 |
# File 'lib/llm_conductor/configuration.rb', line 27 def anthropic(api_key: nil, **) @providers[:anthropic] = { api_key: api_key || ENV['ANTHROPIC_API_KEY'], ** } end |
#anthropic_api_key ⇒ Object
Legacy compatibility methods
100 101 102 |
# File 'lib/llm_conductor/configuration.rb', line 100 def anthropic_api_key provider_config(:anthropic)[:api_key] end |
#anthropic_api_key=(value) ⇒ Object
104 105 106 |
# File 'lib/llm_conductor/configuration.rb', line 104 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.
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/llm_conductor/configuration.rb', line 67 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
132 133 134 |
# File 'lib/llm_conductor/configuration.rb', line 132 def gemini_api_key provider_config(:gemini)[:api_key] end |
#gemini_api_key=(value) ⇒ Object
136 137 138 |
# File 'lib/llm_conductor/configuration.rb', line 136 def gemini_api_key=(value) gemini(api_key: value) end |
#groq(api_key: nil, **options) ⇒ Object
Configure Groq provider
79 80 81 82 83 84 |
# File 'lib/llm_conductor/configuration.rb', line 79 def groq(api_key: nil, **) @providers[:groq] = { api_key: api_key || ENV['GROQ_API_KEY'], ** } end |
#groq_api_key ⇒ Object
140 141 142 |
# File 'lib/llm_conductor/configuration.rb', line 140 def groq_api_key provider_config(:groq)[:api_key] end |
#groq_api_key=(value) ⇒ Object
144 145 146 |
# File 'lib/llm_conductor/configuration.rb', line 144 def groq_api_key=(value) groq(api_key: value) end |
#ollama(base_url: nil, **options) ⇒ Object
Configure Ollama provider
44 45 46 47 48 49 |
# File 'lib/llm_conductor/configuration.rb', line 44 def ollama(base_url: nil, **) @providers[:ollama] = { base_url: base_url || ENV['OLLAMA_ADDRESS'] || 'http://localhost:11434', ** } end |
#ollama_address ⇒ Object
124 125 126 |
# File 'lib/llm_conductor/configuration.rb', line 124 def ollama_address provider_config(:ollama)[:base_url] end |
#ollama_address=(value) ⇒ Object
128 129 130 |
# File 'lib/llm_conductor/configuration.rb', line 128 def ollama_address=(value) ollama(base_url: value) end |
#openai(api_key: nil, organization: nil, **options) ⇒ Object
Configure OpenAI provider
35 36 37 38 39 40 41 |
# File 'lib/llm_conductor/configuration.rb', line 35 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
108 109 110 |
# File 'lib/llm_conductor/configuration.rb', line 108 def openai_api_key provider_config(:openai)[:api_key] end |
#openai_api_key=(value) ⇒ Object
112 113 114 |
# File 'lib/llm_conductor/configuration.rb', line 112 def openai_api_key=(value) openai(api_key: value) end |
#openrouter(api_key: nil, **options) ⇒ Object
Configure OpenRouter provider
52 53 54 55 56 57 |
# File 'lib/llm_conductor/configuration.rb', line 52 def openrouter(api_key: nil, **) @providers[:openrouter] = { api_key: api_key || ENV['OPENROUTER_API_KEY'], ** } end |
#openrouter_api_key ⇒ Object
116 117 118 |
# File 'lib/llm_conductor/configuration.rb', line 116 def openrouter_api_key provider_config(:openrouter)[:api_key] end |
#openrouter_api_key=(value) ⇒ Object
120 121 122 |
# File 'lib/llm_conductor/configuration.rb', line 120 def openrouter_api_key=(value) openrouter(api_key: value) end |
#provider_config(provider) ⇒ Object
Get provider configuration
95 96 97 |
# File 'lib/llm_conductor/configuration.rb', line 95 def provider_config(provider) @providers[provider.to_sym] || {} end |
#zai(api_key: nil, **options) ⇒ Object
Configure Z.ai provider
87 88 89 90 91 92 |
# File 'lib/llm_conductor/configuration.rb', line 87 def zai(api_key: nil, **) @providers[:zai] = { api_key: api_key || ENV['ZAI_API_KEY'], ** } end |
#zai_api_key ⇒ Object
148 149 150 |
# File 'lib/llm_conductor/configuration.rb', line 148 def zai_api_key provider_config(:zai)[:api_key] end |
#zai_api_key=(value) ⇒ Object
152 153 154 |
# File 'lib/llm_conductor/configuration.rb', line 152 def zai_api_key=(value) zai(api_key: value) end |