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, **options) ⇒ Object
Configure Google Gemini provider.
- #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
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
89 90 91 |
# File 'lib/llm_conductor/configuration.rb', line 89 def anthropic_api_key provider_config(:anthropic)[:api_key] end |
#anthropic_api_key=(value) ⇒ Object
93 94 95 |
# File 'lib/llm_conductor/configuration.rb', line 93 def anthropic_api_key=(value) anthropic(api_key: value) end |
#gemini(api_key: nil, **options) ⇒ Object
Configure Google Gemini provider
60 61 62 63 64 65 |
# File 'lib/llm_conductor/configuration.rb', line 60 def gemini(api_key: nil, **) @providers[:gemini] = { api_key: api_key || ENV['GEMINI_API_KEY'], ** } end |
#gemini_api_key ⇒ Object
121 122 123 |
# File 'lib/llm_conductor/configuration.rb', line 121 def gemini_api_key provider_config(:gemini)[:api_key] end |
#gemini_api_key=(value) ⇒ Object
125 126 127 |
# File 'lib/llm_conductor/configuration.rb', line 125 def gemini_api_key=(value) gemini(api_key: value) end |
#groq(api_key: nil, **options) ⇒ Object
Configure Groq provider
68 69 70 71 72 73 |
# File 'lib/llm_conductor/configuration.rb', line 68 def groq(api_key: nil, **) @providers[:groq] = { api_key: api_key || ENV['GROQ_API_KEY'], ** } end |
#groq_api_key ⇒ Object
129 130 131 |
# File 'lib/llm_conductor/configuration.rb', line 129 def groq_api_key provider_config(:groq)[:api_key] end |
#groq_api_key=(value) ⇒ Object
133 134 135 |
# File 'lib/llm_conductor/configuration.rb', line 133 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
113 114 115 |
# File 'lib/llm_conductor/configuration.rb', line 113 def ollama_address provider_config(:ollama)[:base_url] end |
#ollama_address=(value) ⇒ Object
117 118 119 |
# File 'lib/llm_conductor/configuration.rb', line 117 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
97 98 99 |
# File 'lib/llm_conductor/configuration.rb', line 97 def openai_api_key provider_config(:openai)[:api_key] end |
#openai_api_key=(value) ⇒ Object
101 102 103 |
# File 'lib/llm_conductor/configuration.rb', line 101 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
105 106 107 |
# File 'lib/llm_conductor/configuration.rb', line 105 def openrouter_api_key provider_config(:openrouter)[:api_key] end |
#openrouter_api_key=(value) ⇒ Object
109 110 111 |
# File 'lib/llm_conductor/configuration.rb', line 109 def openrouter_api_key=(value) openrouter(api_key: value) end |
#provider_config(provider) ⇒ Object
Get provider configuration
84 85 86 |
# File 'lib/llm_conductor/configuration.rb', line 84 def provider_config(provider) @providers[provider.to_sym] || {} end |
#zai(api_key: nil, **options) ⇒ Object
Configure Z.ai provider
76 77 78 79 80 81 |
# File 'lib/llm_conductor/configuration.rb', line 76 def zai(api_key: nil, **) @providers[:zai] = { api_key: api_key || ENV['ZAI_API_KEY'], ** } end |
#zai_api_key ⇒ Object
137 138 139 |
# File 'lib/llm_conductor/configuration.rb', line 137 def zai_api_key provider_config(:zai)[:api_key] end |
#zai_api_key=(value) ⇒ Object
141 142 143 |
# File 'lib/llm_conductor/configuration.rb', line 141 def zai_api_key=(value) zai(api_key: value) end |