openllmetry icon indicating copy to clipboard operation
openllmetry copied to clipboard

Add support for OpenAI batch completions API

Open kowshik24 opened this issue 8 months ago • 3 comments

Fixes #1689

Add support for OpenAI's batch completions API.

  • Instrumentation: Update packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/__init__.py to add support for batch completions in the OpenAIInstrumentor class. Import necessary modules and wrap the create_batch methods for both synchronous and asynchronous completions.
  • Completion Wrappers: Update packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/completion_wrappers.py to add new wrapper functions for batch completions. Handle request and response attributes for batch completions.
  • Tests: Add tests for batch completions in packages/opentelemetry-instrumentation-openai/tests/traces/test_completions.py. Include tests for both synchronous and asynchronous batch completions. Verify span attributes and response handling.

For more details, open the Copilot Workspace session.


[!IMPORTANT] Add support for OpenAI batch completions API with instrumentation, completion wrappers, and tests.

  • Instrumentation:
    • Update __init__.py to support batch completions in OpenAIInstrumentor.
    • Wrap create_batch methods for sync and async completions.
  • Completion Wrappers:
    • Add batch_completion_wrapper and abatch_completion_wrapper in completion_wrappers.py.
    • Handle request and response attributes for batch completions.
  • Tests:
    • Add tests for batch completions in test_completions.py.
    • Include tests for sync and async batch completions, verifying span attributes and response handling.

This description was created by Ellipsis for a01cf0b1d753586ac93a05084c53ac129aac363f. It will automatically update as commits are pushed.

kowshik24 avatar Mar 28 '25 10:03 kowshik24

@nirga I have made the changes could you please take a look?

kowshik24 avatar Mar 28 '25 15:03 kowshik24

@nirga Please take a look I have added the tests

kowshik24 avatar Mar 28 '25 18:03 kowshik24

@kowshik24 checking if you're still working on this?

nirga avatar Apr 03 '25 15:04 nirga