Exception: ActiveGenie::InvalidProviderError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/active_genie/errors/invalid_provider_error.rb

Constant Summary collapse

TEXT =
<<~TEXT
  Invalid provider: %<provider>s

  To configure ActiveGenie, you can either:
  1. Set up global configuration:
     ```ruby
     ActiveGenie.configure do |config|
       config.providers.default = 'openai'
       config.providers.openai.api_key = 'your_api_key'
       # ... other configuration options
     end
     ```

  2. Or pass configuration directly to the method call:
     ```ruby
     ActiveGenie::Extraction.call(
       arg1,
       arg2,
       config: {
         providers: {
           default: 'openai',
           openai: {
             api_key: 'your_api_key'
           }
         }
       }
     )
     ```

  Available providers: %<available_providers>s
TEXT

Instance Method Summary collapse

Constructor Details

#initialize(provider) ⇒ InvalidProviderError

Returns a new instance of InvalidProviderError.



37
38
39
# File 'lib/active_genie/errors/invalid_provider_error.rb', line 37

def initialize(provider)
  super(format(TEXT, provider:, available_providers:))
end

Instance Method Details

#available_providersObject



41
42
43
# File 'lib/active_genie/errors/invalid_provider_error.rb', line 41

def available_providers
  ActiveGenie.configuration.providers.valid.keys.join(', ')
end