Hello everyone,
I’m trying to build a chatbot that generates matplotlib graphs.
I achieved it, but I am not able to show the graphs in the chat history.
This is my code:
msgs = StreamlitChatMessageHistory()
--- Agent creation
question = st.chat_input('Ask your question')
for msg in msgs.messages:
if type(msg.content) == str:
st.chat_message(msg.type).write(msg.content)
else:
st.chat_message(msg.type).pyplot(msg.content)
if question:
answer = agent_executor.invoke({'input':question})['output']
if ('Plot' or 'plot') not in question:
st.chat_message('human').write(question)
st.chat_message('ai').write(answer)
else:
st.chat_message('human').write(question)
st.chat_message('ai').pyplot(answer)
It creates the graph when asked, but does not keep it in chat history. Why?
Many thanks for your help.