Skip to content

Fix deprecated OpenAI v0 API and add requirements.txt#3

Open
rafaym1 wants to merge 1 commit into
hjian42:v2.0from
rafaym1:fix/openai-v1-migration
Open

Fix deprecated OpenAI v0 API and add requirements.txt#3
rafaym1 wants to merge 1 commit into
hjian42:v2.0from
rafaym1:fix/openai-v1-migration

Conversation

@rafaym1
Copy link
Copy Markdown

@rafaym1 rafaym1 commented Apr 23, 2026

What

run_bfi.py and run_creative_writing.py use openai.ChatCompletion.create() which was removed in openai>=1.0.0 (Nov 2023). Anyone installing the package today gets v1.x and hits an AttributeError immediately.

Also adds a missing requirements.txt and updates the README setup instructions (the referenced audiencenlp conda environment was not included in the repo).

Changes

  • run_bfi.py / run_creative_writing.py: migrate to openai>=1.0.0 client API
    • import openaifrom openai import OpenAI
    • removed hardcoded empty openai.api_key = "" / openai.organization = ""
    • openai.ChatCompletion.create()client.chat.completions.create()
    • response access: response["choices"][0]["message"]["content"]response.choices[0].message.content
    • API key now read from OPENAI_API_KEY environment variable
  • requirements.txt: added (was missing entirely)
  • README.md: replaced conda activate audiencenlp with pip install -r requirements.txt and env var setup instructions

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.

1 participant