Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #279 #757

Merged
merged 2 commits into from
Nov 24, 2023
Merged

Conversation

monarchwadia
Copy link
Collaborator

@monarchwadia monarchwadia commented Nov 24, 2023

Why are these changes needed?

This is a popular issue, #279 which seems to be happening when an OpenAI-compatible API has a specific minor discrepancy from spec in the error response scenario.

Sometimes, when building an OpenAI-compatible API, the main inference scenario is built very well but the API's error response is not fully compliant.

I was building an OpenAI-compatible endpoint. In my case, my error response had an error object that was a string instead of an object.

This was my version, which was slightly off

    const errorObject = {
        "error":  "Authorization failed: there was a problem with the API key."
    }

This is what OpenAI would have returned

    const errorObject = {
        "error": {
          "message": "Authorization failed: there was a problem with the API key.",
          "type": "invalid_request_error",
          "param": null,
          "code": null
      }
    }

error_code=error_data.get("code") will throw because it is expecting error_code to be an object with a property code and in my case, error was a string.

Related issue number

#279

Checks

@codecov-commenter
Copy link

codecov-commenter commented Nov 24, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (c705c6a) 27.82% compared to head (29eb6df) 37.29%.

Files Patch % Lines
autogen/oai/completion.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #757      +/-   ##
==========================================
+ Coverage   27.82%   37.29%   +9.47%     
==========================================
  Files          27       27              
  Lines        3479     3480       +1     
  Branches      788      789       +1     
==========================================
+ Hits          968     1298     +330     
+ Misses       2440     2062     -378     
- Partials       71      120      +49     
Flag Coverage Δ
unittests 37.24% <0.00%> (+9.47%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Collaborator

@sonichi sonichi left a comment

Choose a reason for hiding this comment

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

Thanks for the fix. Please note that this file is for the old openai api <1. For openai>=1, we have switched to the OpenAIWrapper in client.py.

@sonichi sonichi added this pull request to the merge queue Nov 24, 2023
Merged via the queue into microsoft:main with commit 2800112 Nov 24, 2023
52 of 58 checks passed
@sonichi sonichi mentioned this pull request Dec 3, 2023
3 tasks
whiskyboy pushed a commit to whiskyboy/autogen that referenced this pull request Apr 17, 2024
Co-authored-by: Qingyun Wu <qingyun.wu@psu.edu>
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.

None yet

4 participants