TypeError: 'HumanMessage' object is not subscriptable

I am trying to create a chatbot using Langchain and HuggingFace and Streamlit’s Chat Message function.

It works fine for the first message and correctly answers it, but when I send 2nd message it shows this error:

TypeError: ‘HumanMessage’ object is not subscriptable

Traceback:

File "/home/ahsan/.local/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 542, in _run_script
    exec(code, module.__dict__)File "/home/ahsan/Desktop/Projects/ChatbotWithRAG/app.py", line 120, in <module>
    main()File "/home/ahsan/Desktop/Projects/ChatbotWithRAG/app.py", line 92, in main
    with st.chat_message(msg['role']):

It looks you need to ask this to langchain devs (not their bot…)

What relates this case, you maw check attribute-based access, like msg.role

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