Skip to content

Conversation

@AyushSawant18588
Copy link
Contributor

@AyushSawant18588 AyushSawant18588 commented Oct 10, 2024

Describe the change
When the inference engine returns an error response that is not of type openai.ErrorResponse, a decode error occurs, leading to the loss of the original error message from the inference engine. To address this issue, this PR implements a change in the go-openai client that ensures the error from the inference engine is included in the openai.RequestError response. This enhancement preserves the original error information, providing clearer insights into the underlying issues.

Describe your solution
Introduced a new field called Body of type []byte in the openai.RequestError struct. This field stores the byte slice of the error response body received from the inference engine when the error response does not conform to the openai.ErrorResponse type. This enhancement allows to retain the original error message. Now that the byte slice of the error response body is included, clients using this library can unmarshal it on their end to obtain the correct error message.

Issue: #874

@codecov
Copy link

codecov bot commented Oct 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.04%. Comparing base (774fc9d) to head (9caa8d3).
Report is 61 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #873      +/-   ##
==========================================
+ Coverage   98.46%   99.04%   +0.58%     
==========================================
  Files          24       26       +2     
  Lines        1364     1462      +98     
==========================================
+ Hits         1343     1448     +105     
+ Misses         15        8       -7     
  Partials        6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@johnugeorge
Copy link

@sashabaranov Can you please look into this?

Copy link
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.

Thank you for this improvement! Error-handling was historically a hard area :D

@sashabaranov sashabaranov merged commit cfe15ff into sashabaranov:master Oct 14, 2024
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