Skip to content

fix(py/plugins/openai): empty choices raises IndexError on the non-streaming path #6232

Description

@hilariie

_generate indexes choices[0] without checking the list is non-empty, so a completion with no choices raises IndexError instead of anything a caller can handle. The debug log one line above already guards for it.

The trigger is a well-formed 200: a gateway returning a usage-only completion, or a content filter that drops the choice rather than annotating it. _generate_stream is unaffected, since it skips chunks that carry no choices.

The two references disagree, so this needs a decision rather than a straight port. JS returns the usage-only response with no message; Go errors with ErrInvalidOutput.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions