unofficial-chatgpt-api
unofficial-chatgpt-api copied to clipboard
Improve response time
Hi, thanks for the great repo! Currently, the python scripts waits 10 seconds before returning the response. This can lead to errors for example if the result takes longer.
You can take this code (or something similar) that looks for the loading indicator and immediately returns the result when the indicator disappears.
...
send_message(message)
# Check if an answer was received
while True:
# Check loading indicator
loading = PAGE.query_selector_all(
"div[class*='result-streaming']")
if len(loading) == 0:
response = get_last_message()
break
print("Response: ", response)
...
Thanks for the great work!