Class: Legate::Agentic::Decision
- Inherits:
-
Data
- Object
- Data
- Legate::Agentic::Decision
- Defined in:
- lib/legate/agentic/decision.rb
Overview
One step of an agentic loop: the model either calls a tool or gives a final answer. Immutable.
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#answer ⇒ Object
readonly
Returns the value of attribute answer.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#thought ⇒ Object
readonly
Returns the value of attribute thought.
-
#tool ⇒ Object
readonly
Returns the value of attribute tool.
Class Method Summary collapse
- .final(answer:, thought: nil) ⇒ Object
-
.invalid(thought: nil) ⇒ Object
An unusable decision (the model returned neither a valid tool call nor a final answer).
- .tool(tool:, params:, thought: nil) ⇒ Object
Instance Method Summary collapse
-
#action(value) ⇒ Object
readonly
:tool or :final.
- #final? ⇒ Boolean
- #invalid? ⇒ Boolean
-
#params(value) ⇒ Object
readonly
tool arguments (when action == :tool).
-
#to_step ⇒ Hash
The plan step hash that PlanExecutor#execute_step expects.
-
#tool(value) ⇒ Object
readonly
the tool to call (when action == :tool).
- #tool? ⇒ Boolean
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action
15 16 17 |
# File 'lib/legate/agentic/decision.rb', line 15 def action @action end |
#answer ⇒ Object (readonly)
Returns the value of attribute answer
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/legate/agentic/decision.rb', line 15 Decision = Data.define(:action, :thought, :tool, :params, :answer) do def self.tool(tool:, params:, thought: nil) new(action: :tool, thought: thought, tool: tool.to_sym, params: params || {}, answer: nil) end def self.final(answer:, thought: nil) new(action: :final, thought: thought, tool: nil, params: {}, answer: answer) end # An unusable decision (the model returned neither a valid tool call nor a # final answer). def self.invalid(thought: nil) new(action: :invalid, thought: thought, tool: nil, params: {}, answer: nil) end def final? action == :final end def tool? action == :tool && !tool.nil? && !tool.to_s.empty? end def invalid? !final? && !tool? end # The plan step hash that PlanExecutor#execute_step expects. # @return [Hash] def to_step { tool: tool, params: params } end end |
#params ⇒ Object (readonly)
Returns the value of attribute params
15 16 17 |
# File 'lib/legate/agentic/decision.rb', line 15 def params @params end |
#thought ⇒ Object (readonly)
Returns the value of attribute thought
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/legate/agentic/decision.rb', line 15 Decision = Data.define(:action, :thought, :tool, :params, :answer) do def self.tool(tool:, params:, thought: nil) new(action: :tool, thought: thought, tool: tool.to_sym, params: params || {}, answer: nil) end def self.final(answer:, thought: nil) new(action: :final, thought: thought, tool: nil, params: {}, answer: answer) end # An unusable decision (the model returned neither a valid tool call nor a # final answer). def self.invalid(thought: nil) new(action: :invalid, thought: thought, tool: nil, params: {}, answer: nil) end def final? action == :final end def tool? action == :tool && !tool.nil? && !tool.to_s.empty? end def invalid? !final? && !tool? end # The plan step hash that PlanExecutor#execute_step expects. # @return [Hash] def to_step { tool: tool, params: params } end end |
#tool ⇒ Object (readonly)
Returns the value of attribute tool
15 16 17 |
# File 'lib/legate/agentic/decision.rb', line 15 def tool @tool end |
Class Method Details
.final(answer:, thought: nil) ⇒ Object
20 21 22 |
# File 'lib/legate/agentic/decision.rb', line 20 def self.final(answer:, thought: nil) new(action: :final, thought: thought, tool: nil, params: {}, answer: answer) end |
.invalid(thought: nil) ⇒ Object
An unusable decision (the model returned neither a valid tool call nor a final answer).
26 27 28 |
# File 'lib/legate/agentic/decision.rb', line 26 def self.invalid(thought: nil) new(action: :invalid, thought: thought, tool: nil, params: {}, answer: nil) end |
.tool(tool:, params:, thought: nil) ⇒ Object
16 17 18 |
# File 'lib/legate/agentic/decision.rb', line 16 def self.tool(tool:, params:, thought: nil) new(action: :tool, thought: thought, tool: tool.to_sym, params: params || {}, answer: nil) end |
Instance Method Details
#action=(value) ⇒ Object (readonly)
:tool or :final
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/legate/agentic/decision.rb', line 15 Decision = Data.define(:action, :thought, :tool, :params, :answer) do def self.tool(tool:, params:, thought: nil) new(action: :tool, thought: thought, tool: tool.to_sym, params: params || {}, answer: nil) end def self.final(answer:, thought: nil) new(action: :final, thought: thought, tool: nil, params: {}, answer: answer) end # An unusable decision (the model returned neither a valid tool call nor a # final answer). def self.invalid(thought: nil) new(action: :invalid, thought: thought, tool: nil, params: {}, answer: nil) end def final? action == :final end def tool? action == :tool && !tool.nil? && !tool.to_s.empty? end def invalid? !final? && !tool? end # The plan step hash that PlanExecutor#execute_step expects. # @return [Hash] def to_step { tool: tool, params: params } end end |
#final? ⇒ Boolean
30 31 32 |
# File 'lib/legate/agentic/decision.rb', line 30 def final? action == :final end |
#invalid? ⇒ Boolean
38 39 40 |
# File 'lib/legate/agentic/decision.rb', line 38 def invalid? !final? && !tool? end |
#params=(value) ⇒ Object (readonly)
tool arguments (when action == :tool)
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/legate/agentic/decision.rb', line 15 Decision = Data.define(:action, :thought, :tool, :params, :answer) do def self.tool(tool:, params:, thought: nil) new(action: :tool, thought: thought, tool: tool.to_sym, params: params || {}, answer: nil) end def self.final(answer:, thought: nil) new(action: :final, thought: thought, tool: nil, params: {}, answer: answer) end # An unusable decision (the model returned neither a valid tool call nor a # final answer). def self.invalid(thought: nil) new(action: :invalid, thought: thought, tool: nil, params: {}, answer: nil) end def final? action == :final end def tool? action == :tool && !tool.nil? && !tool.to_s.empty? end def invalid? !final? && !tool? end # The plan step hash that PlanExecutor#execute_step expects. # @return [Hash] def to_step { tool: tool, params: params } end end |
#to_step ⇒ Hash
The plan step hash that PlanExecutor#execute_step expects.
44 45 46 |
# File 'lib/legate/agentic/decision.rb', line 44 def to_step { tool: tool, params: params } end |
#tool=(value) ⇒ Object (readonly)
the tool to call (when action == :tool)
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/legate/agentic/decision.rb', line 15 Decision = Data.define(:action, :thought, :tool, :params, :answer) do def self.tool(tool:, params:, thought: nil) new(action: :tool, thought: thought, tool: tool.to_sym, params: params || {}, answer: nil) end def self.final(answer:, thought: nil) new(action: :final, thought: thought, tool: nil, params: {}, answer: answer) end # An unusable decision (the model returned neither a valid tool call nor a # final answer). def self.invalid(thought: nil) new(action: :invalid, thought: thought, tool: nil, params: {}, answer: nil) end def final? action == :final end def tool? action == :tool && !tool.nil? && !tool.to_s.empty? end def invalid? !final? && !tool? end # The plan step hash that PlanExecutor#execute_step expects. # @return [Hash] def to_step { tool: tool, params: params } end end |
#tool? ⇒ Boolean
34 35 36 |
# File 'lib/legate/agentic/decision.rb', line 34 def tool? action == :tool && !tool.nil? && !tool.to_s.empty? end |