Skip to content

fix: chat stream returns an error response with a 'data: ' prefix#396

Merged
sashabaranov merged 4 commits into
sashabaranov:masterfrom
liushuangls:fix-stream-resp-err
Jun 20, 2023
Merged

fix: chat stream returns an error response with a 'data: ' prefix#396
sashabaranov merged 4 commits into
sashabaranov:masterfrom
liushuangls:fix-stream-resp-err

Conversation

@liushuangls
Copy link
Copy Markdown
Contributor

@liushuangls liushuangls commented Jun 20, 2023

Occasionally, OpenAI may return the following error message:

data: {"error":{"message":"The server experienced an error while processing your request. We apologize for the inconvenience!", "type":"server_error", "param":null,"code":null)}

data: [DONE]

In such cases, the stream.Recv() function will return a successful status along with a zero-value response.

@liushuangls liushuangls changed the title fix: chat stream resp has 'data: ' prefix fix: chat stream error response has a 'data: ' prefix Jun 20, 2023
@liushuangls liushuangls changed the title fix: chat stream error response has a 'data: ' prefix fix: chat stream return error response has a 'data: ' prefix Jun 20, 2023
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 20, 2023

Codecov Report

Merging #396 (abfcd5e) into master (b095938) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #396      +/-   ##
==========================================
+ Coverage   95.26%   95.32%   +0.05%     
==========================================
  Files          17       17              
  Lines         676      684       +8     
==========================================
+ Hits          644      652       +8     
  Misses         22       22              
  Partials       10       10              
Impacted Files Coverage Δ
stream_reader.go 100.00% <100.00%> (ø)

@liushuangls liushuangls changed the title fix: chat stream return error response has a 'data: ' prefix fix: chat stream returns an error response with a 'data: ' prefix Jun 20, 2023
Copy link
Copy Markdown
Owner

@sashabaranov sashabaranov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you!

@sashabaranov sashabaranov merged commit e948150 into sashabaranov:master Jun 20, 2023
@liushuangls
Copy link
Copy Markdown
Contributor Author

@sashabaranov Please release it.

@pmilanez
Copy link
Copy Markdown

+1 for release it, i'm facing this problem and not been able to retry it based on the error

@liushuangls liushuangls deleted the fix-stream-resp-err branch August 12, 2025 06:31
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.

3 participants