Module: Legate::Agentic
- Defined in:
- lib/legate/agentic/decision.rb,
lib/legate/agentic/loop.rb
Overview
The agentic (observe -> think -> act) execution strategy.
Defined Under Namespace
Instance Attribute Summary collapse
-
#answer ⇒ Object
readonly
the final answer (when action == :final).
-
#thought ⇒ Object
readonly
the model’s reasoning.
Instance Method Summary collapse
-
#action(value) ⇒ Object
:tool or :final.
-
#params(value) ⇒ Object
tool arguments (when action == :tool).
-
#tool(value) ⇒ Object
the tool to call (when action == :tool).
Instance Attribute Details
#answer ⇒ Object (readonly)
the final answer (when action == :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 |
#thought ⇒ Object (readonly)
the model’s reasoning
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 |
Instance Method Details
#action=(value) ⇒ Object
: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 |
#params=(value) ⇒ Object
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 |
#tool=(value) ⇒ Object
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 |