Class: SmartAgent::ToolContext
- Inherits:
-
Object
- Object
- SmartAgent::ToolContext
- Defined in:
- lib/smart_agent/tool.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#input_params ⇒ Object
Returns the value of attribute input_params.
-
#proc ⇒ Object
Returns the value of attribute proc.
Instance Method Summary collapse
- #call_tool(name, params = {}) ⇒ Object
- #call_worker(name, params) ⇒ Object
- #desc(description) ⇒ Object
-
#initialize(tool) ⇒ ToolContext
constructor
A new instance of ToolContext.
- #param_define(name, description, type) ⇒ Object
- #params ⇒ Object
- #tool_proc(&block) ⇒ Object
Constructor Details
#initialize(tool) ⇒ ToolContext
76 77 78 |
# File 'lib/smart_agent/tool.rb', line 76 def initialize(tool) @tool = tool end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
74 75 76 |
# File 'lib/smart_agent/tool.rb', line 74 def description @description end |
#input_params ⇒ Object
Returns the value of attribute input_params.
74 75 76 |
# File 'lib/smart_agent/tool.rb', line 74 def input_params @input_params end |
#proc ⇒ Object
Returns the value of attribute proc.
74 75 76 |
# File 'lib/smart_agent/tool.rb', line 74 def proc @proc end |
Instance Method Details
#call_tool(name, params = {}) ⇒ Object
97 98 99 100 101 102 103 104 |
# File 'lib/smart_agent/tool.rb', line 97 def call_tool(name, params = {}) if Tool.find_tool(name) return Tool.find_tool(name).call(params) end if server_name = MCPClient.find_server_by_tool_name(name) return MCPClient.new(server_name).call(name, params) end end |
#call_worker(name, params) ⇒ Object
92 93 94 95 |
# File 'lib/smart_agent/tool.rb', line 92 def call_worker(name, params) params[:with_history] = false SmartAgent.prompt_engine.call_worker(name, params) end |
#desc(description) ⇒ Object
88 89 90 |
# File 'lib/smart_agent/tool.rb', line 88 def desc(description) @description = description end |
#param_define(name, description, type) ⇒ Object
84 85 86 |
# File 'lib/smart_agent/tool.rb', line 84 def param_define(name, description, type) params[name] = { description: description, type: type } end |
#params ⇒ Object
80 81 82 |
# File 'lib/smart_agent/tool.rb', line 80 def params @params ||= {} end |
#tool_proc(&block) ⇒ Object
106 107 108 |
# File 'lib/smart_agent/tool.rb', line 106 def tool_proc(&block) @proc = block end |