Greetings to all. I am new to openai and I want to create and maintain a session with the openai library. But I keep getting “openai.error.InvalidRequestError: Unrecognized request argument supplied: context”
This is the code generated by the AI
import openai
import uuid
Set up the OpenAI API credentials
openai.api_key = “YOUR_API_KEY”
Generate a unique conversation ID for the current user
conversation_id = str(uuid.uuid4())
Initialize the conversation with a welcome message
prompt = “Hello, I’m ChatGPT! How can I assist you today?”
response = openai.Completion.create(
engine=“text-davinci-002”,
prompt=prompt,
temperature=0.5,
max_tokens=50,
n=1,
stop=None,
context=conversation_id,
)
Print the response from ChatGPT
print(response.choices[0].text)
Continue the conversation with a new prompt and the same conversation ID
prompt = “Can you tell me more about your question?”
response = openai.Completion.create(
engine=“text-davinci-002”,
prompt=prompt,
temperature=0.5,
max_tokens=50,
n=1,
stop=None,
context=conversation_id,
)
Print the response from ChatGPT
print(response.choices[0].text)