Class: RailsAiBridge::ToolResultCache::CachedTool
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- RailsAiBridge::ToolResultCache::CachedTool
- Defined in:
- lib/rails_ai_bridge/tool_result_cache.rb
Overview
Wraps a tool class so that calls are routed through the cache.
Instance Method Summary collapse
- #call(server_context: nil, **arguments) ⇒ MCP::Tool::Response
-
#initialize(tool_class) ⇒ CachedTool
constructor
A new instance of CachedTool.
Constructor Details
#initialize(tool_class) ⇒ CachedTool
Returns a new instance of CachedTool.
21 22 23 24 25 |
# File 'lib/rails_ai_bridge/tool_result_cache.rb', line 21 def initialize(tool_class) super @tool_class = tool_class @server_context_param = detect_server_context_param(tool_class.method(:call)) end |
Instance Method Details
#call(server_context: nil, **arguments) ⇒ MCP::Tool::Response
30 31 32 33 34 |
# File 'lib/rails_ai_bridge/tool_result_cache.rb', line 30 def call(server_context: nil, **arguments) ToolResultCache.fetch_response(@tool_class.tool_name, arguments) do invoke_tool(arguments, server_context) end end |