After asking a question, the following error occurred:
You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.
You can run `openai migrate` to automatically upgrade your codebase to use the 1.0.0 interface.
Alternatively, you can pin your installation to the old version, e.g. `pip install openai==0.28`
A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742
To remediate this, I had to use several tools to migrate the code base in glados.py that resulted in the following changes:
./glados.py
import signal
import subprocess
import whisper
-import openai
+from openai import OpenAI
+
+client = OpenAI(api_key=os.environ.get('OPENAI_API_KEY'))
import random
import torch
from utils.tools import prepare_text
-openai.api_key = os.environ.get('OPENAI_API_KEY')
def speech_to_text(stt_model):
# if recording stops too early or late mess with vad_mode sample_rate and silence_seconds
vad_mode = 3
print(conversation_history)
if use_gpt:
- full_response = openai.ChatCompletion.create(
- model="gpt-3.5-turbo",
- messages=[ {"role": "system", "content": conversation_history} ],
- temperature=0.7,
- max_tokens=1024,
- top_p=1,
- )
+ full_response = client.chat.completions.create(model="gpt-3.5-turbo",
+ messages=[ {"role": "system", "content": conversation_history} ],
+ temperature=0.7,
+ max_tokens=1024,
+ top_p=1)
# Extract the response text from the API response
message = full_response.choices[0].message.content.strip()
else:
Just placing this here for information if anyone else runs into this.
After asking a question, the following error occurred:
To remediate this, I had to use several tools to migrate the code base in glados.py that resulted in the following changes:
Just placing this here for information if anyone else runs into this.