Class: LlmConductor::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/llm_conductor/configuration.rb

Overview

Configuration class for managing API keys, endpoints, and default settings

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration



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_modelObject

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_vendorObject

Returns the value of attribute default_vendor.



7
8
9
# File 'lib/llm_conductor/configuration.rb', line 7

def default_vendor
  @default_vendor
end

#loggerObject

Returns the value of attribute logger.



7
8
9
# File 'lib/llm_conductor/configuration.rb', line 7

def logger
  @logger
end

#max_retriesObject

Returns the value of attribute max_retries.



7
8
9
# File 'lib/llm_conductor/configuration.rb', line 7

def max_retries
  @max_retries
end

#providersObject (readonly)

Returns the value of attribute providers.



8
9
10
# File 'lib/llm_conductor/configuration.rb', line 8

def providers
  @providers
end

#retry_delayObject

Returns the value of attribute retry_delay.



7
8
9
# File 'lib/llm_conductor/configuration.rb', line 7

def retry_delay
  @retry_delay
end

#timeoutObject

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, **options)
  @providers[:anthropic] = {
    api_key: api_key || ENV['ANTHROPIC_API_KEY'],
    **options
  }
end

#anthropic_api_keyObject

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, **options)
  @providers[:gemini] = {
    api_key: api_key || ENV['GEMINI_API_KEY'],
    **options
  }
end

#gemini_api_keyObject



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, **options)
  @providers[:groq] = {
    api_key: api_key || ENV['GROQ_API_KEY'],
    **options
  }
end

#groq_api_keyObject



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, **options)
  @providers[:ollama] = {
    base_url: base_url || ENV['OLLAMA_ADDRESS'] || 'http://localhost:11434',
    **options
  }
end

#ollama_addressObject



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, **options)
  @providers[:openai] = {
    api_key: api_key || ENV['OPENAI_API_KEY'],
    organization: organization || ENV['OPENAI_ORG_ID'],
    **options
  }
end

#openai_api_keyObject



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, **options)
  @providers[:openrouter] = {
    api_key: api_key || ENV['OPENROUTER_API_KEY'],
    **options
  }
end

#openrouter_api_keyObject



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, **options)
  @providers[:zai] = {
    api_key: api_key || ENV['ZAI_API_KEY'],
    **options
  }
end

#zai_api_keyObject



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