Class: ComposableAgents::Agent
- Inherits:
-
Object
- Object
- ComposableAgents::Agent
- Includes:
- Mixins::Logger
- Defined in:
- lib/composable_agents/agent.rb
Overview
Abstract computational unit that transforms inputs into outputs. Agents may internally use LLMs, tools, or other agents. Agents are stateless: they take input artifacts and return output artifacts.
Direct Known Subclasses
Public API collapse
-
#name ⇒ String?
readonly
The agent name, if any.
Public API collapse
-
#full_name ⇒ String
Return the full name of the agent.
-
#initialize(name: nil, composable_agents_dir: '.composable_agents') ⇒ Agent
constructor
Constructor.
Methods included from Mixins::Logger
Internal collapse
-
#run(**input_artifacts) ⇒ Hash{Symbol => Object}
Execute the agent to generate some output artifacts based on some input artifacts.
Constructor Details
#initialize(name: nil, composable_agents_dir: '.composable_agents') ⇒ Agent
Constructor
17 18 19 20 21 22 23 |
# File 'lib/composable_agents/agent.rb', line 17 def initialize( name: nil, composable_agents_dir: '.composable_agents' ) @name = name @composable_agents_dir = composable_agents_dir end |
Instance Attribute Details
#name ⇒ String? (readonly)
Returns The agent name, if any.
11 12 13 |
# File 'lib/composable_agents/agent.rb', line 11 def name @name end |
Instance Method Details
#full_name ⇒ String
Return the full name of the agent. This method is intended to be overridden by subclasses to give better full names, tailored to the kind of agent. The full name can be used in logs and traces to better identify the agent.
30 31 32 |
# File 'lib/composable_agents/agent.rb', line 30 def full_name "#{name || 'Unnamed'}#{" (#{self.class.name.split('::').last})" if self.class != Agent && self.class.name}" end |
#run(**input_artifacts) ⇒ Hash{Symbol => Object}
Execute the agent to generate some output artifacts based on some input artifacts.
40 41 42 |
# File 'lib/composable_agents/agent.rb', line 40 def run(**input_artifacts) raise NotImplementedError, 'This method should be implemented by an Agent subclass' end |