Class: SmartAgent::ToolContext

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_agent/tool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#descriptionObject

Returns the value of attribute description.



74
75
76
# File 'lib/smart_agent/tool.rb', line 74

def description
  @description
end

#input_paramsObject

Returns the value of attribute input_params.



74
75
76
# File 'lib/smart_agent/tool.rb', line 74

def input_params
  @input_params
end

#procObject

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

#paramsObject



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