Class: ActiveAgent::Provider::Base
- Inherits:
-
Object
- Object
- ActiveAgent::Provider::Base
- Defined in:
- lib/active_agent/provider.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#chat(messages, tools: [], &block) ⇒ Object
Abstract methods to be implemented by adapters.
- #format_tools(tools) ⇒ Object
-
#initialize(api_key:, model:) ⇒ Base
constructor
A new instance of Base.
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_key ⇒ Object (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 |
#model ⇒ Object (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
18 19 20 |
# File 'lib/active_agent/provider.rb', line 18 def chat(, tools: [], &block) raise NotImplementedError, "#{self.class} must implement #chat" end |
#format_tools(tools) ⇒ Object
22 23 24 |
# File 'lib/active_agent/provider.rb', line 22 def format_tools(tools) raise NotImplementedError, "#{self.class} must implement #format_tools" end |