I am a data science student that is trying to do more projects in order to fill out my resume, but I am encountering an error when running the code:
import openai
openai.api_key = ‘sk-……’
def chat_with_gpt(prompt):
response = openai.ChatCompletion.create(
model=”gpt-3.5-turbo”, # or “gpt-4”
messages=[{“role”: “user”, “content”: prompt}]
)
return response[‘choices’][0][‘message’][‘content’].strip()
while True:
user_input = input(“You: “)
if user_input.lower() in [“quit”, “exit”, “bye”]:
print(“Chatbot: Goodbye!”)
break
response = chat_with_gpt(user_input)
print(f”Chatbot: {response}”)
#here is the error I run into:
APIRemovedInV1 Traceback (most recent call last) Cell In[59], line 16 14 print("Chatbot: Goodbye!") 15 break ---> 16 response = chat_with_gpt(user_input) 17 print(f"Chatbot: {response}") Cell In[59], line 5, in chat_with_gpt(prompt) 4 def chat_with_gpt(prompt): ----> 5 response = openai.ChatCompletion.create( 6 model="gpt-3.5-turbo", # or "gpt-4" 7 messages=[{"role": "user", "content": prompt}] 8 ) 9 return response['choices'][0]['message']['content'].strip() File ~anaconda3Libsite-packagesopenailib_old_api.py:39, in APIRemovedInV1Proxy.__call__(self, *_args, **_kwargs) 38 def __call__(self, *_args: Any, **_kwargs: Any) -> Any: ---> 39 raise APIRemovedInV1(symbol=self._symbol) APIRemovedInV1: You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0 - see the README at 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-pythonhttps://github.com/openai/openai-python/discussions/742
submitted by /u/Potential-Train9553
[link] [comments]
r/learnpython I am a data science student that is trying to do more projects in order to fill out my resume, but I am encountering an error when running the code: import openai openai.api_key = ‘sk-……’ def chat_with_gpt(prompt): response = openai.ChatCompletion.create( model=”gpt-3.5-turbo”, # or “gpt-4” messages=[{“role”: “user”, “content”: prompt}] ) return response[‘choices’][0][‘message’][‘content’].strip() while True: user_input = input(“You: “) if user_input.lower() in [“quit”, “exit”, “bye”]: print(“Chatbot: Goodbye!”) break response = chat_with_gpt(user_input) print(f”Chatbot: {response}”) #here is the error I run into: APIRemovedInV1 Traceback (most recent call last) Cell In[59], line 16 14 print(“Chatbot: Goodbye!”) 15 break —> 16 response = chat_with_gpt(user_input) 17 print(f”Chatbot: {response}”) Cell In[59], line 5, in chat_with_gpt(prompt) 4 def chat_with_gpt(prompt): —-> 5 response = openai.ChatCompletion.create( 6 model=”gpt-3.5-turbo”, # or “gpt-4” 7 messages=[{“role”: “user”, “content”: prompt}] 8 ) 9 return response[‘choices’][0][‘message’][‘content’].strip() File ~anaconda3Libsite-packagesopenailib_old_api.py:39, in APIRemovedInV1Proxy.__call__(self, *_args, **_kwargs) 38 def __call__(self, *_args: Any, **_kwargs: Any) -> Any: —> 39 raise APIRemovedInV1(symbol=self._symbol) APIRemovedInV1: You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0 – see the README at 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-pythonhttps://github.com/openai/openai-python/discussions/742 submitted by /u/Potential-Train9553 [link] [comments]
I am a data science student that is trying to do more projects in order to fill out my resume, but I am encountering an error when running the code:
import openai
openai.api_key = ‘sk-……’
def chat_with_gpt(prompt):
response = openai.ChatCompletion.create(
model=”gpt-3.5-turbo”, # or “gpt-4”
messages=[{“role”: “user”, “content”: prompt}]
)
return response[‘choices’][0][‘message’][‘content’].strip()
while True:
user_input = input(“You: “)
if user_input.lower() in [“quit”, “exit”, “bye”]:
print(“Chatbot: Goodbye!”)
break
response = chat_with_gpt(user_input)
print(f”Chatbot: {response}”)
#here is the error I run into:
APIRemovedInV1 Traceback (most recent call last) Cell In[59], line 16 14 print("Chatbot: Goodbye!") 15 break ---> 16 response = chat_with_gpt(user_input) 17 print(f"Chatbot: {response}") Cell In[59], line 5, in chat_with_gpt(prompt) 4 def chat_with_gpt(prompt): ----> 5 response = openai.ChatCompletion.create( 6 model="gpt-3.5-turbo", # or "gpt-4" 7 messages=[{"role": "user", "content": prompt}] 8 ) 9 return response['choices'][0]['message']['content'].strip() File ~anaconda3Libsite-packagesopenailib_old_api.py:39, in APIRemovedInV1Proxy.__call__(self, *_args, **_kwargs) 38 def __call__(self, *_args: Any, **_kwargs: Any) -> Any: ---> 39 raise APIRemovedInV1(symbol=self._symbol) APIRemovedInV1: You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0 - see the README at 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-pythonhttps://github.com/openai/openai-python/discussions/742
submitted by /u/Potential-Train9553
[link] [comments]