Class: ChatSDK::AI::ToolExecutor
- Inherits:
-
Object
- Object
- ChatSDK::AI::ToolExecutor
- Defined in:
- lib/chat_sdk/ai/tool_executor.rb
Instance Method Summary collapse
- #execute(tool_name, arguments) ⇒ Object
-
#initialize(chat:) ⇒ ToolExecutor
constructor
A new instance of ToolExecutor.
Constructor Details
#initialize(chat:) ⇒ ToolExecutor
Returns a new instance of ToolExecutor.
6 7 8 |
# File 'lib/chat_sdk/ai/tool_executor.rb', line 6 def initialize(chat:) @chat = chat end |
Instance Method Details
#execute(tool_name, arguments) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/chat_sdk/ai/tool_executor.rb', line 10 def execute(tool_name, arguments) tool_name = tool_name.to_sym raise ChatSDK::Error, "Unknown tool: #{tool_name}" unless ToolBuilder::TOOL_DEFINITIONS.key?(tool_name) args = arguments.transform_keys(&:to_sym) adapter_name = args[:adapter_name].to_sym send(:"execute_#{tool_name}", adapter_name, args) end |