Class: AnalyticalBrain::Tools::SetGoal
- Inherits:
-
Tools::Base
- Object
- Tools::Base
- AnalyticalBrain::Tools::SetGoal
- Defined in:
- lib/analytical_brain/tools/set_goal.rb
Overview
Creates a goal on the main session. Root goals represent high-level objectives (semantic episodes); sub-goals are TODO-style steps within a root goal. The two-level hierarchy is enforced by the Goal model.
Class Method Summary collapse
Instance Method Summary collapse
- #execute(input) ⇒ String, Hash
-
#initialize(main_session:) ⇒ SetGoal
constructor
A new instance of SetGoal.
Methods inherited from Tools::Base
Constructor Details
#initialize(main_session:) ⇒ SetGoal
Returns a new instance of SetGoal.
32 33 34 |
# File 'lib/analytical_brain/tools/set_goal.rb', line 32 def initialize(main_session:, **) @main_session = main_session end |
Class Method Details
.description ⇒ Object
11 12 |
# File 'lib/analytical_brain/tools/set_goal.rb', line 11 def self.description = "Create a goal on the main session. " \ "Omit parent_goal_id for a root goal, or provide it to create a sub-goal (TODO item)." |
.input_schema ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/analytical_brain/tools/set_goal.rb', line 14 def self.input_schema { type: "object", properties: { description: { type: "string", description: "What needs to be accomplished (1-2 sentences)" }, parent_goal_id: { type: "integer", description: "ID of the parent goal (omit for root goals)" } }, required: %w[description] } end |
.tool_name ⇒ Object
9 |
# File 'lib/analytical_brain/tools/set_goal.rb', line 9 def self.tool_name = "set_goal" |
Instance Method Details
#execute(input) ⇒ String, Hash
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/analytical_brain/tools/set_goal.rb', line 39 def execute(input) description = input["description"].to_s.strip return {error: "Description cannot be blank"} if description.empty? goal = @main_session.goals.create!( description: description, parent_goal_id: input["parent_goal_id"] ) format_confirmation(goal) rescue ActiveRecord::RecordInvalid => error {error: error.record.errors..join(", ")} end |