Class: CircuitBreaker::Executors::LLM::ToolKit
- Inherits:
-
Object
- Object
- CircuitBreaker::Executors::LLM::ToolKit
- Defined in:
- lib/circuit_breaker/executors/llm/tools.rb
Instance Method Summary collapse
- #add_tool(tool) ⇒ Object
- #available_tools ⇒ Object
- #execute_tool(name, **args) ⇒ Object
- #get_tool(name) ⇒ Object
-
#initialize ⇒ ToolKit
constructor
A new instance of ToolKit.
- #tool_descriptions ⇒ Object
Constructor Details
#initialize ⇒ ToolKit
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_tools ⇒ Object
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_descriptions ⇒ Object
45 46 47 |
# File 'lib/circuit_breaker/executors/llm/tools.rb', line 45 def tool_descriptions @tools.values.map(&:to_h) end |