Skip to content

fix: ensure ChatCompletionChunk delta is always ChoiceDelta in final … #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LuminaX-alt
Copy link
Owner

…Azure streaming chunk

Description

Fixes issue openai#1677 where the final streaming chunk for ChatCompletionChunk from Azure OpenAI returns delta as None. This causes issues in typed clients expecting a ChoiceDelta.

Changes

  • Default delta to an empty ChoiceDelta when missing in the final chunk.
  • Ensures consistent typing for all streamed chunks.

Why?

Clients consuming the stream expect delta to always be a valid ChoiceDelta. This change prevents NoneType errors and maintains consistent response structure.

Closes openai#1677

  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Additional context & links

…Azure streaming chunk

### Description
Fixes issue openai#1677 where the final streaming chunk for `ChatCompletionChunk` from Azure OpenAI returns `delta` as `None`. This causes issues in typed clients expecting a `ChoiceDelta`.

### Changes
- Default `delta` to an empty `ChoiceDelta` when missing in the final chunk.
- Ensures consistent typing for all streamed chunks.

### Why?
Clients consuming the stream expect `delta` to always be a valid `ChoiceDelta`. This change prevents `NoneType` errors and maintains consistent response structure.

Closes openai#1677
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typing: when stream is completed, delta in ChatCompletionChunk from azure openai is None; should be ChoiceDelta
1 participant