Hi Charly, Thank You for your reply.
This the output I get when I enter the question I actually want a histogram to be shown here.
And this is what happens in my terminal when the chain is executed.
st.set_page_config(page_title="Talk with CSV")
st.header("Talk with CSV 🤖")
if "messages" not in st.session_state:
st.session_state.messages = []
# Display chat messages from history on app rerun
for message in st.session_state.messages:
with st.chat_message(message["role"]):
st.markdown(message["content"])
file = st.file_uploader("Upload a CSV file", type="csv")
#
if file is not None:
with st.spinner(text="Loading..."):
with NamedTemporaryFile(delete=False) as f: # Create temporary file
f.write(file.getbuffer()) # Save uploaded contents to file
f_path= f.name
memory = ConversationBufferMemory(memory_key="chat_history")
agent = create_csv_agent(
OpenAI(temperature=0), f.name , verbose=True, agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
handle_parsing_errors=True, memory=memory)
st.success('Done!')
# user_question = st.text_input("Ask a question about your CSV: ")
if prompt := st.chat_input("Ask a question about your CSV: "):
# st.chat_message("user").write(prompt)
# # Add user message to chat history
st.session_state.messages.append({"role": "user", "content": prompt})
# # Display user message in chat message container
with st.chat_message("user"):
st.markdown(prompt)
with st.chat_message("assistant"):
st_callback = StreamlitCallbackHandler(st.container())
response = agent.run(prompt, callbacks=[st_callback])
st.session_state.messages.append({"role": "assistant", "content": response})
st.write(response)
And this is how the output is when I try in a ipynb notebook which is what i want in my chat window.


