Class: Brute::Middleware::OtelToolCalls
- Inherits:
-
Object
- Object
- Brute::Middleware::OtelToolCalls
- Defined in:
- lib/brute/middleware/073_otel_tool_call.rb
Overview
Records tool calls the LLM requested as span events.
Runs POST-call: after the LLM responds, inspects ctx.functions for any tool calls the model wants to make, and adds a span event for each one with the tool name, call ID, and arguments.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ OtelToolCalls
constructor
A new instance of OtelToolCalls.
Constructor Details
#initialize(app) ⇒ OtelToolCalls
Returns a new instance of OtelToolCalls.
15 16 17 |
# File 'lib/brute/middleware/073_otel_tool_call.rb', line 15 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/brute/middleware/073_otel_tool_call.rb', line 19 def call(env) #response = @app.call(env) #span = env[:span] #if span # functions = env[:pending_functions] # if functions && !functions.empty? # span.set_attribute("brute.tool_calls.count", functions.size) # functions.each do |fn| # attrs = { # "tool.name" => fn.name.to_s, # "tool.id" => fn.id.to_s, # } # args = fn.arguments # attrs["tool.arguments"] = args.to_json if args # span.add_event("tool_call", attributes: attrs) # end # end #end #response @app.call(env) end |