This is a snippet where I have been encountering the problem:
def generate_response(prompt):
response = openai.chatcompletion.create(
model="gpt-4", # Use "gpt-4" as the model identifier if "gpt-4o" is deprecated
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": prompt}
],
max_tokens=150
)
return response.choices[0].message['content'].strip()
I tried the following to solve the APIRemovedInV1
error:
You have a double typo. You're missing a dot and the letter s.
Change this...
openai.chatcompletion.create
...to this.
openai.chat.completions.create
The full code is:
from openai import OpenAI
client = OpenAI()
completion = client.chat.completions.create()
model="gpt-4",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
)
print(completion.choices[0].message)