diezo / ProGPT

🔥 Free GPT-3.5 Python API
https://buymeacoffee.com/sonii
MIT License
60 stars 8 forks source link

JSON decode failed #2

Closed vlna closed 6 months ago

vlna commented 6 months ago

I am still on https://github.com/diezo/ProGPT/commit/6eaeb7c6516216a425a91649a4ef34f04a5eac1c and I encountered this issue.

My code is a simple loop like

    c = Conversation(token)
    while True:
        p = input('Prompt: ')
        r = c.send(p)
        print(r)
Traceback (most recent call last):
  File "C:\Users\vlna\PycharmProjects\vlna\chatgpt\main.py", line 23, in <module>
    r = c.send(p)
        ^^^^^^^^^
  File "C:\Users\vlna\AppData\Local\Programs\Python\Python312\Lib\site-packages\ProGPT\Conversation.py", line 123, in send
    try: data: dict = json.loads(chunk[6:])
                      ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\vlna\AppData\Local\Programs\Python\Python312\Lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\vlna\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\vlna\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 2 (char 1)

It looks like remote server returned an unexpected content and it made ProGPT code crash. It happened only one time.

diezo commented 6 months ago

I've already fixed this issue in an earlier commit. Just upgrade ProGPT and you should be good to go.

pip install progpt --upgrade