Skip to content

finish_reason missing from streaming responses when None #19

@daveb1976

Description

@daveb1976

The finish_reason field doesn't appear to be being passed through to the client.

Here's an example of the incoming data from OpenAI:

final returned processed chunk: ModelResponseStream(id='chatcmpl-B1z1HwsKbjazcsxVWxtBgG1FEOFEJ', created=1739812588, model='gpt-4o', object='chat.completion.chunk', system_fingerprint='fp_523b9b6e5f', choices=[StreamingChoices(finish_reason=None, index=0, delta=Delta(provider_specific_fields=None, refusal=None, content='?', role=None, function_call=None, tool_calls=None, audio=None), logprobs=None)], stream_options={'include_usage': True}, citations=None)

The response looks like this:

data: {"id":"chatcmpl-B1z1HwsKbjazcsxVWxtBgG1FEOFEJ","created":1739812588,"model":"gpt-4o","object":"chat.completion.chunk","system_fingerprint":"fp_523b9b6e5f","choices":[{"index":0,"delta":{"content":"?"}}],"stream_options":{"include_usage":true}}

It does get returned on the last message when it is something other than None.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions