Class: ActiveAgent::Provider::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/active_agent/provider.rb

Direct Known Subclasses

Anthropic, Gemini, OpenAI

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, model:) ⇒ Base

Returns a new instance of Base.



8
9
10
11
12
13
14
15
# File 'lib/active_agent/provider.rb', line 8

def initialize(api_key:, model:)
  provider_name = self.class.name.split("::").last
  if api_key.to_s.strip.empty?
    raise "ActiveAgent Error: API key for #{provider_name} is not configured. Please set it in config/initializers/active_agent.rb or via environment variables."
  end
  @api_key = api_key
  @model = model
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



6
7
8
# File 'lib/active_agent/provider.rb', line 6

def api_key
  @api_key
end

#modelObject (readonly)

Returns the value of attribute model.



6
7
8
# File 'lib/active_agent/provider.rb', line 6

def model
  @model
end

Instance Method Details

#chat(messages, tools: [], &block) ⇒ Object

Abstract methods to be implemented by adapters

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/active_agent/provider.rb', line 18

def chat(messages, tools: [], &block)
  raise NotImplementedError, "#{self.class} must implement #chat"
end

#format_tools(tools) ⇒ Object

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/active_agent/provider.rb', line 22

def format_tools(tools)
  raise NotImplementedError, "#{self.class} must implement #format_tools"
end