Module: Foam::Otel::LLM::HttpAnthropicShim::RequestPatch

Defined in:
lib/foam/otel/llm/http_anthropic_shim.rb

Instance Method Summary collapse

Instance Method Details

#request(verb, uri, opts = {}) ⇒ Object



260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/foam/otel/llm/http_anthropic_shim.rb', line 260

def request(verb, uri, opts = {})
  unless Foam::Otel::LLM.emit? && HttpAnthropicShim.anthropic_messages?(verb, uri, self)
    return super
  end

  body = HttpAnthropicShim.request_body(opts)
  Foam::Otel::LLM.observe(
    provider: "anthropic",
    request: Foam::Otel::LLM.safe_request(provider: "anthropic") do
      HttpAnthropicShim.request_attributes(body)
    end,
    error_detector: HttpAnthropicShim::ERROR_DETECTOR,
    response_extractor: HttpAnthropicShim::EXTRACTOR
  ) { super }
end