_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.
_generateindexeschoices[0]without checking the list is non-empty, so a completion with no choices raisesIndexErrorinstead 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_streamis 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.