Class: AnalyticalBrain::Tools::SetGoal
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
Methods inherited from Tools::Base
schema, truncation_threshold
Constructor Details
#initialize(main_session:) ⇒ SetGoal
Returns a new instance of SetGoal.
28
29
30
|
# File 'lib/analytical_brain/tools/set_goal.rb', line 28
def initialize(main_session:, **)
@main_session = main_session
end
|
Class Method Details
.description ⇒ Object
11
|
# File 'lib/analytical_brain/tools/set_goal.rb', line 11
def self.description = "Create a goal or sub-goal."
|
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/analytical_brain/tools/set_goal.rb', line 13
def self.input_schema
{
type: "object",
properties: {
description: {
type: "string",
description: "1 sentence."
},
parent_goal_id: {type: "integer"}
},
required: %w[description]
}
end
|
9
|
# File 'lib/analytical_brain/tools/set_goal.rb', line 9
def self.tool_name = "set_goal"
|
Instance Method Details
#execute(input) ⇒ String, Hash
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/analytical_brain/tools/set_goal.rb', line 35
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.full_messages.join(", ")}
end
|