terry3041 / pyChatGPT

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

Realtime printout? #134

Open Hertaspace opened 1 year ago

Hertaspace commented 1 year ago

Hi, it seems the current version prints ChatGPT's message after the message finished, is there any convinient way to realtime display the response (display anything replied by ChatGPT when the whole message is not finished) ? Thanks!

Hertaspace commented 1 year ago

Hi, it seems the current version prints ChatGPT's message after the message finished, is there any convinient way to realtime display the response (display anything replied by ChatGPT when the whole message is not finished) ? Thanks!

just as the way the website does.

iwaitu commented 1 year ago
from pyChatGPT import ChatGPT
session_token = "eyxxxxxx..."
api  = ChatGPT(session_token)
result = api.send_message("你好",True)
print(result["message"])
(chatgpt) D:\chatgpt>python test.py
Traceback (most recent call last):
  File "D:\chatgpt\test.py", line 5, in <module>
    result = api.send_message("你好",True)
  File "C:\Users\iwaitu\anaconda3\envs\chatgpt\lib\site-packages\pyChatGPT\pyChatGPT.py", line 427, in send_message
    for i in self.__stream_message():
  File "C:\Users\iwaitu\anaconda3\envs\chatgpt\lib\site-packages\pyChatGPT\pyChatGPT.py", line 393, in __stream_message
    response = self.driver.find_elements(*chatgpt_small_response)[-1]
IndexError: list index out of range
acheong08 commented 1 year ago

Read the readme