terry3041 / pyChatGPT

An unofficial Python wrapper for OpenAI's ChatGPT API
GNU General Public License v3.0
1.35k stars 255 forks source link

ValueError: Only one message at a time. Please allow any other responses to complete before sending another message, or wait one minute. #101

Closed deezed420 closed 1 year ago

deezed420 commented 1 year ago

When I try to make a query, it says the error in the title. Here is my code:

from pyChatGPT import ChatGPT # Import ChatGPT API

# Variables
questions = []
answers = []
sessiontoken = I can't say that ;)
# Start the api
api = ChatGPT(sessiontoken)

# Read questions
with open("./questions.txt", "r") as f: questions += f.readlines()

# Send query to api
for q in questions: response = api.send_message(q) ; answers.append(response["message"])

# Clean up answers list
answers = [a[:-1] for a in answers]

# Write answers to file
with open("./answers.txt", "w") as f: f.write(''.join(answers))

# Close chrome window
api.clear_conversations()
api.driver.close()

And here is the whole error:

Traceback (most recent call last):
  File "c:\Users\Ender\Dev\OpenAiAPITest\main.py", line 15, in <module>
    for q in questions: response = api.send_message(q) ; answers.append(response["message"])
Traceback (most recent call last):
  File "c:\Users\Ender\Dev\OpenAiAPITest\main.py", line 15, in <module>
    for q in questions: response = api.send_message(q) ; answers.append(response["message"])
                                   ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ender\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyChatGPT\pyChatGPT.py", line 441, in send_message    
    raise ValueError(response.text)
ValueError: Only one message at a time. Please allow any other responses to complete before sending another message, or wait one minute.
deezed420 commented 1 year ago

somehow, it works again when I ran it again without doing anything to the code.