Fix AttributeError: Update OpenAI error imports (Closes #1564) #1577
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thank you for contributing an eval!♥️
🚨 Please make sure your PR follows these guidelines. Failure to follow the guidelines below will result in the PR being closed automatically.
Also note that even if the criteria are met, that does not guarantee the PR will be merged nor GPT-4 access be granted. 🚨
PLEASE READ THIS:
Eval details 📑
Eval name
Fix AttributeError: Update OpenAI error imports for v1.0+ (Closes #1564)
Eval description
A bug fix to remove references to the now-removed
openai.error
module and replace them with the newer top-level exceptions (APIError
,APIConnectionError
, etc.) introduced in OpenAI Python client 1.0+. This PR resolves theAttributeError: module 'openai' has no attribute 'error'
that appears when runningoaieval --help
or importingevals
while on a newer OpenAI library.What makes this a useful eval?
While this PR does not introduce a new eval dataset, it fixes a breaking issue preventing any user from running the existing Evals if they have a newer version of the OpenAI Python client. This ensures better compatibility moving forward and helps the community continue building and testing evals without version conflicts.
Criteria for a good eval ✅
Unique eval value
Eval structure 🏗️
evals/registry/data/{name}
: No new data or YAML—this PR only fixes Python imports.evals/registry/evals/{name}.yaml
: No new YAML needed.Final checklist 👀
Submission agreement
Email address validation
Limited availability acknowledgment
Submit eval
pip install pre-commit; pre-commit install
and verifiedmypy
,black
,isort
,autoflake
, andruff
are running on commit.Eval JSON data
View evals in JSON
Eval
Code Changes
File:
evals/utils/api_utils.py
(and wherever elseopenai.error
was referenced)Testing:
pip install --upgrade openai
(>=1.0).oaieval --help
andpython -c "import evals"
now run withoutAttributeError
.Thank you for reviewing this PR!