I m getting this error for many times ,but could not solve it,please help

running this app locally
github repo :Healthcare-Chatbot/MedIQ-ChatBot-main at main · ibadlaskar/Healthcare-Chatbot · GitHub

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Traceback:

File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 556, in _run_script
    exec(code, module.__dict__)File "C:\Users\Owner\Downloads\MedIQ-ChatBot-main\MedIQ-ChatBot-main\streamlit\pages\app.py", line 109, in <module>
    chat_interface(st.session_state["chat_messages"])File "C:\Users\Owner\Downloads\MedIQ-ChatBot-main\MedIQ-ChatBot-main\streamlit\pages\app.py", line 66, in chat_interface
    bot_response = response.json()['response']File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)

Python 3.9.7
Streamlit, version 1.12.0

Hi @Ibad_Laskar,

Thanks for sharing this question!

The error might be related to the response your code is getting which might be empty or not a valid JSON format.

You can add the try-except block to catch the errors that might be causing the code to break.

this error

ERROR in app: Exception on /chat [POST]
Traceback (most recent call last):
  File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\site-packages\flask\app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\site-packages\flask\app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\site-packages\flask\app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\site-packages\flask\app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "c:\Users\Owner\Downloads\MedIQ-ChatBot-main\MedIQ-ChatBot-main\flask\main.py", line 36, in chat
    inp = request.json['input']
KeyError: 'input'
1 Like

Did you get it working okay?

Now its giving the above error , its not workig, i request u to check my github repository if possible ,then this could be very helpful.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.

The latest error is suggesting that there’s no key named “input” in your json file. You do a print statement to inspect the entire json so you can see which key to use.