-
Notifications
You must be signed in to change notification settings - Fork 76
JSONDecodeError: Extra data: line 1 column 61 (char 60) #5
Copy link
Copy link
Open
Description
Hi. I am getting the following error:
JSONDecodeError: Extra data: line 1 column 61 (char 60)
Traceback:
File "C:\Users\AppData\Local\anaconda3\envs\py311_test\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 565, in _run_script
exec(code, module.__dict__)
File "C:\Users\Desktop\GenAI\app\app2_test\interface.py", line 72, in <module>
decoded_response = decode_response(response)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Desktop\GenAI\app\app2_test\interface.py", line 17, in decode_response
return json.loads(response)
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\AppData\Local\anaconda3\envs\py311_test\Lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\\AppData\Local\anaconda3\envs\py311_test\Lib\json\decoder.py", line 340, in decode
raise JSONDecodeError("Extra data", s, end)
It looks like something wrong with decode_response function.
I changed it to:
def decode_response(response: str) -> dict:
lines = response.splitlines()
json_line = lines[0]
return json.loads(json_line)
and it started working for simple questions, but it fails for most questions (e.g. plot something)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels