Class: ActiveGenie::Config::Providers::ProviderBase
- Inherits:
-
Object
- Object
- ActiveGenie::Config::Providers::ProviderBase
- Defined in:
- lib/active_genie/configs/providers/provider_base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#api_key ⇒ Object
writeonly
Sets the attribute api_key.
-
#api_url ⇒ Object
writeonly
Sets the attribute api_url.
-
#default_model ⇒ Object
writeonly
Sets the attribute default_model.
-
#organization ⇒ Object
writeonly
Sets the attribute organization.
Instance Method Summary collapse
-
#initialize(api_key: nil, organization: nil, api_url: nil, default_model: nil) ⇒ ProviderBase
constructor
A new instance of ProviderBase.
-
#to_h ⇒ Hash
Returns a hash representation of the configuration.
-
#valid? ⇒ Boolean
Validates the configuration.
-
#valid_model?(_model) ⇒ Boolean
Checks if the given model is valid for this provider.
Constructor Details
#initialize(api_key: nil, organization: nil, api_url: nil, default_model: nil) ⇒ ProviderBase
Returns a new instance of ProviderBase.
7 8 9 10 11 12 |
# File 'lib/active_genie/configs/providers/provider_base.rb', line 7 def initialize(api_key: nil, organization: nil, api_url: nil, default_model: nil) @api_key = api_key @organization = organization @api_url = api_url @default_model = default_model end |
Instance Attribute Details
#api_key=(value) ⇒ Object (writeonly)
Sets the attribute api_key
14 15 16 |
# File 'lib/active_genie/configs/providers/provider_base.rb', line 14 def api_key=(value) @api_key = value end |
#api_url=(value) ⇒ Object (writeonly)
Sets the attribute api_url
14 15 16 |
# File 'lib/active_genie/configs/providers/provider_base.rb', line 14 def api_url=(value) @api_url = value end |
#default_model=(value) ⇒ Object (writeonly)
Sets the attribute default_model
14 15 16 |
# File 'lib/active_genie/configs/providers/provider_base.rb', line 14 def default_model=(value) @default_model = value end |
#organization=(value) ⇒ Object (writeonly)
Sets the attribute organization
14 15 16 |
# File 'lib/active_genie/configs/providers/provider_base.rb', line 14 def organization=(value) @organization = value end |
Instance Method Details
#to_h ⇒ Hash
Returns a hash representation of the configuration.
32 33 34 35 36 37 38 39 |
# File 'lib/active_genie/configs/providers/provider_base.rb', line 32 def to_h { api_key: @api_key, api_url: @api_url, organization: @organization, default_model: @default_model } end |
#valid? ⇒ Boolean
Validates the configuration.
18 19 20 |
# File 'lib/active_genie/configs/providers/provider_base.rb', line 18 def valid? api_key && api_url end |
#valid_model?(_model) ⇒ Boolean
Checks if the given model is valid for this provider. Example provider.valid_model?(‘gpt-4’) => true
25 26 27 |
# File 'lib/active_genie/configs/providers/provider_base.rb', line 25 def valid_model?(_model) false end |