openllmetry
openllmetry copied to clipboard
Add support for OpenAI batch completions API
Fixes #1689
Add support for OpenAI's batch completions API.
- Instrumentation: Update
packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/__init__.pyto add support for batch completions in theOpenAIInstrumentorclass. Import necessary modules and wrap thecreate_batchmethods for both synchronous and asynchronous completions. - Completion Wrappers: Update
packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/completion_wrappers.pyto 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__.pyto support batch completions inOpenAIInstrumentor.- Wrap
create_batchmethods for sync and async completions.- Completion Wrappers:
- Add
batch_completion_wrapperandabatch_completion_wrapperincompletion_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
for a01cf0b1d753586ac93a05084c53ac129aac363f. It will automatically update as commits are pushed.
@nirga I have made the changes could you please take a look?
@nirga Please take a look I have added the tests
@kowshik24 checking if you're still working on this?