openai-python icon indicating copy to clipboard operation
openai-python copied to clipboard

Fixed CLI streamed chat completions.

Open MikeAmy opened this issue 1 year ago • 0 comments

Streamed chat completions use a different response structure vs non-streamed, i.e. deltas, which caused KeyError exceptions. Also these token deltas may have roles, and there may be empty deltas at the end of a completion. Handle these cases sensibly without breaking the non-streamed path.

I manually tested both the streamed and non-streamed paths, but no unit tests, sorry, was busy.

MikeAmy avatar Mar 19 '23 04:03 MikeAmy