Module: LlmCostTracker::Integrations::Openai::ChatCompletionsPatch
- Defined in:
- lib/llm_cost_tracker/integrations/openai.rb
Instance Method Summary collapse
- #create(*args, **kwargs) ⇒ Object
- #stream(*args, **kwargs) ⇒ Object
- #stream_raw(*args, **kwargs) ⇒ Object
Instance Method Details
#create(*args, **kwargs) ⇒ Object
394 395 396 397 398 399 400 401 402 403 404 405 406 |
# File 'lib/llm_cost_tracker/integrations/openai.rb', line 394 def create(*args, **kwargs) request = LlmCostTracker::Integrations::Openai.request_params(args, kwargs) LlmCostTracker::Integrations::Openai.enforce_budget!(request: request) started_at = LlmCostTracker::Timing.now_monotonic response = super(*LlmCostTracker::Integrations::Openai.normalize_sdk_args(args, kwargs)) LlmCostTracker::Integrations::Openai.record_response( response, request: request, latency_ms: LlmCostTracker::Timing.elapsed_ms(started_at), host: LlmCostTracker::Integrations::Openai.client_host_for(self) ) response end |
#stream(*args, **kwargs) ⇒ Object
408 409 410 411 412 |
# File 'lib/llm_cost_tracker/integrations/openai.rb', line 408 def stream(*args, **kwargs) LlmCostTracker::Integrations::Openai.wrap_stream_call(args, kwargs, self) do |normalized, _| super(*normalized) end end |
#stream_raw(*args, **kwargs) ⇒ Object
414 415 416 417 418 |
# File 'lib/llm_cost_tracker/integrations/openai.rb', line 414 def stream_raw(*args, **kwargs) LlmCostTracker::Integrations::Openai.wrap_stream_call(args, kwargs, self) do |normalized, _| super(*normalized) end end |