Module: LlmCostTracker::Integrations::Openai::ChatCompletionsPatch
- Defined in:
- lib/llm_cost_tracker/integrations/openai.rb
Instance Method Summary collapse
Instance Method Details
#create(*args, **kwargs) ⇒ Object
197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/llm_cost_tracker/integrations/openai.rb', line 197 def create(*args, **kwargs) LlmCostTracker::Integrations::Openai.enforce_budget! started_at = LlmCostTracker::Timing.now_monotonic response = super LlmCostTracker::Integrations::Openai.record_response( response, request: LlmCostTracker::Integrations::Openai.request_params(args, kwargs), latency_ms: LlmCostTracker::Integrations::Openai.elapsed_ms(started_at) ) response end |
#stream_raw(*args, **kwargs) ⇒ Object
209 210 211 212 213 214 215 |
# File 'lib/llm_cost_tracker/integrations/openai.rb', line 209 def stream_raw(*args, **kwargs) request = LlmCostTracker::Integrations::Openai.request_params(args, kwargs) LlmCostTracker::Integrations::Openai.enforce_budget! collector = LlmCostTracker::Integrations::Openai.stream_collector(request) stream = super LlmCostTracker::Integrations::Openai.track_stream(stream, collector: collector) end |