Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ChatGpt] JSONDecodeError: Expecting value: line 1 column 1 (char 0) #2241

Open
iG8R opened this issue Sep 22, 2024 · 0 comments
Open

[ChatGpt] JSONDecodeError: Expecting value: line 1 column 1 (char 0) #2241

iG8R opened this issue Sep 22, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@iG8R
Copy link

iG8R commented Sep 22, 2024

Bug description
Trying the new ChatGpt provider in the beginning everything was fine, but after some time the following error appeared in response to any request:

Using ChatGpt provider and gpt-4o-mini model
ERROR:root:Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "c:\gpt4free\venv\Lib\site-packages\g4f\api\__init__.py", line 167, in chat_completions
    return JSONResponse((await response).to_json())
                         ^^^^^^^^^^^^^^
  File "c:\gpt4free\venv\Lib\site-packages\g4f\client\async_client.py", line 71, in iter_append_model_and_provider
    async for chunk in response:
  File "c:\gpt4free\venv\Lib\site-packages\g4f\client\async_client.py", line 42, in iter_response
    async for chunk in response:
  File "c:\gpt4free\venv\Lib\site-packages\g4f\client\helper.py", line 46, in cast_iter_async
    for chunk in iter:
  File "c:\gpt4free\venv\Lib\site-packages\g4f\Provider\ChatGpt.py", line 194, in create_completion
    data = json.loads(line.decode()[6:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\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 1 (char 0)
INFO:     127.0.0.1:57845 - "POST /v1/chat/completions?provider=ChatGpt HTTP/1.1" 500 Internal Server Error

Screenshots
image

curl -H "Content-Type: application/json" -H "Authorization: Bearer" -d "{\"model\":\"gpt-4o-mini\",\"messages\":[{\"role\":\"system\",\"content\":\"Say this is a test!\"},{\"role\":\"user\",\"content\":\"Hi, there!\"}],\"temperature\":0.7}" http://127.0.0.1:1337/v1/chat/completions?provider=ChatGpt
image

Environment

  • python version - 3.12
  • location ( are you in a cloudfare flagged country ) ? - No.
@iG8R iG8R added the bug Something isn't working label Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants