-
Notifications
You must be signed in to change notification settings - Fork 47
[🐛 Fix]: Upgrade deprecated OpenAI API client and replace davinci model with gpt-3.5-turbo #21
Copy link
Copy link
Open
Description
Description 📝
The Synthesize.ipynb research notebook uses the deprecated openai==0.28 Python client and the davinci completion model, which are no longer supported by OpenAI and throw InvalidRequestError / deprecation warnings when researchers attempt to run the data synthesis pipeline.
Problem 🚨
openai==0.28is deprecated and incompatible with the current OpenAI API.openai.Completion.createwith thedavinciengine is no longer available.- The hardcoded
openai.api_keyassignment is a security anti-pattern. - No error handling around API calls causes the entire batch loop to crash on quota/rate-limit errors.
Proposed Solution 💡
- Upgrade the pip dependency to
openai>=1.0.0. - Initialize the client securely using
os.environ.get('OPENAI_API_KEY')instead of hardcoding the key. - Replace the deprecated
openai.Completion.create/davincicall with the modernclient.chat.completions.createsyntax usinggpt-3.5-turbo. - Wrap API calls in a
try/exceptblock to gracefully handle rate-limit or quota errors without crashing the batch loop.
References 🔗
Acceptance Criteria ✅
-
Synthesize.ipynbruns without deprecation warnings orInvalidRequestError. - API key is read from environment variables, not hardcoded.
- Text generation uses
gpt-3.5-turboviaclient.chat.completions.create. - Batch loop handles rate-limit errors gracefully.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels