Class: CircuitBreaker::Executors::LLM::ToolKit

Inherits:
Object
  • Object
show all
Defined in:
lib/circuit_breaker/executors/llm/tools.rb

Instance Method Summary collapse

Constructor Details

#initializeToolKit

Returns a new instance of ToolKit.



29
30
31
# File 'lib/circuit_breaker/executors/llm/tools.rb', line 29

def initialize
  @tools = {}
end

Instance Method Details

#add_tool(tool) ⇒ Object



33
34
35
# File 'lib/circuit_breaker/executors/llm/tools.rb', line 33

def add_tool(tool)
  @tools[tool.name] = tool
end

#available_toolsObject



41
42
43
# File 'lib/circuit_breaker/executors/llm/tools.rb', line 41

def available_tools
  @tools.values
end

#execute_tool(name, **args) ⇒ Object



49
50
51
52
53
# File 'lib/circuit_breaker/executors/llm/tools.rb', line 49

def execute_tool(name, **args)
  tool = get_tool(name)
  raise "Tool '#{name}' not found" unless tool
  tool.execute(**args)
end

#get_tool(name) ⇒ Object



37
38
39
# File 'lib/circuit_breaker/executors/llm/tools.rb', line 37

def get_tool(name)
  @tools[name]
end

#tool_descriptionsObject



45
46
47
# File 'lib/circuit_breaker/executors/llm/tools.rb', line 45

def tool_descriptions
  @tools.values.map(&:to_h)
end