Module: LlmCostTracker::Integrations::Anthropic::MessagesPatch

Defined in:
lib/llm_cost_tracker/integrations/anthropic.rb

Instance Method Summary collapse

Instance Method Details

#create(*args, **kwargs) ⇒ Object



147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/llm_cost_tracker/integrations/anthropic.rb', line 147

def create(*args, **kwargs)
  request = LlmCostTracker::Integrations::Anthropic.request_params(args, kwargs)
  LlmCostTracker::Integrations::Anthropic.enforce_budget!(request: request)
  started_at = LlmCostTracker::Timing.now_monotonic
  message = super
  LlmCostTracker::Integrations::Anthropic.record_message(
    message,
    request: request,
    latency_ms: LlmCostTracker::Timing.elapsed_ms(started_at)
  )
  message
end

#stream(*args, **kwargs) ⇒ Object



160
161
162
# File 'lib/llm_cost_tracker/integrations/anthropic.rb', line 160

def stream(*args, **kwargs)
  LlmCostTracker::Integrations::Anthropic.wrap_stream_call(args, kwargs) { super }
end

#stream_raw(*args, **kwargs) ⇒ Object



164
165
166
# File 'lib/llm_cost_tracker/integrations/anthropic.rb', line 164

def stream_raw(*args, **kwargs)
  LlmCostTracker::Integrations::Anthropic.wrap_stream_call(args, kwargs) { super }
end