Class: ActiveGenie::Config::Providers::ProviderBase

Inherits:
Object
  • Object
show all
Defined in:
lib/active_genie/configs/providers/provider_base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Parameters:

  • value

    the value to set the attribute api_key to.



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

Parameters:

  • value

    the value to set the attribute api_url to.



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

Parameters:

  • value

    the value to set the attribute default_model to.



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

Parameters:

  • value

    the value to set the attribute organization to.



14
15
16
# File 'lib/active_genie/configs/providers/provider_base.rb', line 14

def organization=(value)
  @organization = value
end

Instance Method Details

#to_hHash

Returns a hash representation of the configuration.

Parameters:

  • config (Hash)

    Additional key-value pairs to merge into the hash.

Returns:

  • (Hash)

    The configuration settings as a hash.



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.

Returns:

  • (Boolean)

    True if the configuration is valid, false otherwise.



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

Parameters:

  • model (String, nil)

    The model name to validate.

Returns:

  • (Boolean)

    True if the model is valid, false otherwise.



25
26
27
# File 'lib/active_genie/configs/providers/provider_base.rb', line 25

def valid_model?(_model)
  false
end