Class: RubyCanUseLLM::Configuration
- Inherits:
-
Object
- Object
- RubyCanUseLLM::Configuration
- Defined in:
- lib/rubycanusellm/configuration.rb
Constant Summary collapse
- SUPPORTED_PROVIDERS =
%i[openai anthropic voyage mistral ollama].freeze
- EMBEDDING_PROVIDERS =
%i[openai voyage mistral ollama].freeze
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#embedding_api_key ⇒ Object
Returns the value of attribute embedding_api_key.
-
#embedding_provider ⇒ Object
Returns the value of attribute embedding_provider.
-
#model ⇒ Object
Returns the value of attribute model.
-
#provider ⇒ Object
Returns the value of attribute provider.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
- #validate_embedding! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 15 16 17 18 |
# File 'lib/rubycanusellm/configuration.rb', line 10 def initialize @provider = nil @api_key = nil @model = nil @timeout = 30 @embedding_provider = nil @embedding_api_key = nil @base_url = nil end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/rubycanusellm/configuration.rb', line 8 def api_key @api_key end |
#base_url ⇒ Object
Returns the value of attribute base_url.
8 9 10 |
# File 'lib/rubycanusellm/configuration.rb', line 8 def base_url @base_url end |
#embedding_api_key ⇒ Object
Returns the value of attribute embedding_api_key.
8 9 10 |
# File 'lib/rubycanusellm/configuration.rb', line 8 def @embedding_api_key end |
#embedding_provider ⇒ Object
Returns the value of attribute embedding_provider.
8 9 10 |
# File 'lib/rubycanusellm/configuration.rb', line 8 def @embedding_provider end |
#model ⇒ Object
Returns the value of attribute model.
8 9 10 |
# File 'lib/rubycanusellm/configuration.rb', line 8 def model @model end |
#provider ⇒ Object
Returns the value of attribute provider.
8 9 10 |
# File 'lib/rubycanusellm/configuration.rb', line 8 def provider @provider end |
#timeout ⇒ Object
Returns the value of attribute timeout.
8 9 10 |
# File 'lib/rubycanusellm/configuration.rb', line 8 def timeout @timeout end |
Instance Method Details
#validate! ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/rubycanusellm/configuration.rb', line 20 def validate! raise Error, "provider is required. Use :openai, :anthropic, :mistral, or :ollama" if provider.nil? raise Error, "api_key is required" if provider != :ollama && (api_key.nil? || api_key.empty?) return if SUPPORTED_PROVIDERS.include?(provider) raise Error, "Unknown provider: #{provider}. Supported: #{SUPPORTED_PROVIDERS.join(", ")}" end |
#validate_embedding! ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rubycanusellm/configuration.rb', line 30 def effective = || provider unless EMBEDDING_PROVIDERS.include?(effective) raise Error, "#{provider} does not support embeddings. Set config.embedding_provider to :openai or :voyage and provide config.embedding_api_key" end return unless && (.nil? || .empty?) raise Error, "embedding_api_key is required when embedding_provider is set" end |