Class: AnalyticalBrain::Tools::ReadWorkflow
- Inherits:
-
Tools::Base
- Object
- Tools::Base
- AnalyticalBrain::Tools::ReadWorkflow
- Defined in:
- lib/analytical_brain/tools/read_workflow.rb
Overview
Reads and activates a workflow on the main session. Returns the full workflow content so the brain can create goals from it. Also sets the workflow as active on the session, injecting its content into the main agent’s “Your Expertise” section.
Class Method Summary collapse
Instance Method Summary collapse
- #execute(input) ⇒ String, Hash
-
#initialize(main_session:) ⇒ ReadWorkflow
constructor
A new instance of ReadWorkflow.
Methods inherited from Tools::Base
Constructor Details
#initialize(main_session:) ⇒ ReadWorkflow
Returns a new instance of ReadWorkflow.
29 30 31 |
# File 'lib/analytical_brain/tools/read_workflow.rb', line 29 def initialize(main_session:, **) @main_session = main_session end |
Class Method Details
.description ⇒ Object
12 13 |
# File 'lib/analytical_brain/tools/read_workflow.rb', line 12 def self.description = "Read a workflow's full content and activate it on the session. " \ "Use the content to create appropriate goals with set_goal." |
.input_schema ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/analytical_brain/tools/read_workflow.rb', line 15 def self.input_schema { type: "object", properties: { name: { type: "string", description: "Name of the workflow to read (from the available workflows list)" } }, required: %w[name] } end |
.tool_name ⇒ Object
10 |
# File 'lib/analytical_brain/tools/read_workflow.rb', line 10 def self.tool_name = "read_workflow" |
Instance Method Details
#execute(input) ⇒ String, Hash
36 37 38 39 40 41 42 43 44 |
# File 'lib/analytical_brain/tools/read_workflow.rb', line 36 def execute(input) workflow_name = input["name"].to_s.strip return {error: "Workflow name cannot be blank"} if workflow_name.empty? workflow = @main_session.activate_workflow(workflow_name) format_workflow(workflow) rescue Workflows::InvalidDefinitionError => error {error: error.} end |