Class: DeepAgentsRb::ReactAgent
- Inherits:
-
Object
- Object
- DeepAgentsRb::ReactAgent
- Defined in:
- lib/deepagents/deepagentsrb/sub_agent.rb
Overview
Simple React Agent implementation
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#prompt ⇒ Object
readonly
Returns the value of attribute prompt.
-
#state_class ⇒ Object
readonly
Returns the value of attribute state_class.
-
#tools ⇒ Object
readonly
Returns the value of attribute tools.
Instance Method Summary collapse
-
#initialize(model, prompt, tools, state_class) ⇒ ReactAgent
constructor
A new instance of ReactAgent.
- #invoke(state) ⇒ Object
Constructor Details
#initialize(model, prompt, tools, state_class) ⇒ ReactAgent
Returns a new instance of ReactAgent.
101 102 103 104 105 106 |
# File 'lib/deepagents/deepagentsrb/sub_agent.rb', line 101 def initialize(model, prompt, tools, state_class) @model = model @prompt = prompt @tools = tools @state_class = state_class end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
99 100 101 |
# File 'lib/deepagents/deepagentsrb/sub_agent.rb', line 99 def model @model end |
#prompt ⇒ Object (readonly)
Returns the value of attribute prompt.
99 100 101 |
# File 'lib/deepagents/deepagentsrb/sub_agent.rb', line 99 def prompt @prompt end |
#state_class ⇒ Object (readonly)
Returns the value of attribute state_class.
99 100 101 |
# File 'lib/deepagents/deepagentsrb/sub_agent.rb', line 99 def state_class @state_class end |
#tools ⇒ Object (readonly)
Returns the value of attribute tools.
99 100 101 |
# File 'lib/deepagents/deepagentsrb/sub_agent.rb', line 99 def tools @tools end |
Instance Method Details
#invoke(state) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/deepagents/deepagentsrb/sub_agent.rb', line 108 def invoke(state) # In a real implementation, this would use the LLM to: # 1. Process the input state # 2. Decide which tool to use # 3. Call the tool # 4. Process the tool result # 5. Repeat until done # 6. Return the final response # For now, we'll just return a simple response state.update( messages: [{ role: "assistant", content: "I've completed the task: #{state.messages.last[:content]}" }] ) state end |