Class: ComposableAgents::Agent
- Inherits:
-
Object
- Object
- ComposableAgents::Agent
- 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.
-
#runs_info ⇒ Array<RunInfo>
readonly
The list of run information of this agent.
Public API collapse
-
#full_name ⇒ String
Return the full name of the agent.
-
#initialize(name: nil, composable_agents_dir: '.composable_agents', logger: ComposableAgents::Logger.instance) ⇒ Agent
constructor
Constructor.
-
#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', logger: ComposableAgents::Logger.instance) ⇒ Agent
Constructor
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/composable_agents/agent.rb', line 22 def initialize( name: nil, composable_agents_dir: '.composable_agents', logger: ComposableAgents::Logger.instance ) @name = name @composable_agents_dir = composable_agents_dir @provided_logger = logger @runs_info = [] @current_run_info = nil end |
Instance Attribute Details
#name ⇒ String? (readonly)
Returns The agent name, if any.
9 10 11 |
# File 'lib/composable_agents/agent.rb', line 9 def name @name end |
#runs_info ⇒ Array<RunInfo> (readonly)
Returns The list of run information of this agent.
12 13 14 |
# File 'lib/composable_agents/agent.rb', line 12 def runs_info @runs_info 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.
39 40 41 |
# File 'lib/composable_agents/agent.rb', line 39 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.
47 48 49 50 51 52 |
# File 'lib/composable_agents/agent.rb', line 47 def run(**_input_artifacts) @current_run_info = RunInfo.new @runs_info << @current_run_info publish_run_info(started_at: Time.now) {} end |