Class: MagicQuery::Providers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/magic_query/providers/base.rb

Direct Known Subclasses

Claude, Gemini, OpenAI

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, model: nil, temperature: 0.3, max_tokens: 1000) ⇒ Base

Returns a new instance of Base.



10
11
12
13
14
15
# File 'lib/magic_query/providers/base.rb', line 10

def initialize(api_key:, model: nil, temperature: 0.3, max_tokens: 1000)
  @api_key = api_key
  @model = model || default_model
  @temperature = temperature
  @max_tokens = max_tokens
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



8
9
10
# File 'lib/magic_query/providers/base.rb', line 8

def api_key
  @api_key
end

#max_tokensObject (readonly)

Returns the value of attribute max_tokens.



8
9
10
# File 'lib/magic_query/providers/base.rb', line 8

def max_tokens
  @max_tokens
end

#modelObject (readonly)

Returns the value of attribute model.



8
9
10
# File 'lib/magic_query/providers/base.rb', line 8

def model
  @model
end

#temperatureObject (readonly)

Returns the value of attribute temperature.



8
9
10
# File 'lib/magic_query/providers/base.rb', line 8

def temperature
  @temperature
end

Instance Method Details

#generate(prompt) ⇒ Object

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/magic_query/providers/base.rb', line 17

def generate(prompt)
  raise NotImplementedError, 'Subclasses must implement #generate'
end