Replicate the app from the image.
To upload files, please first save the app
import streamlit as st
# Set page title
st.title("Talk2Data + StreamLit")
# Create sidebar
with st.sidebar:
# File upload widget
uploaded_file = st.file_uploader("File Upload", type=["csv", "txt", "pdf"])
# Drag and drop area (Note: file_uploader already provides drag&drop functionality)
st.markdown("#### Drag & Drop")
st.markdown("*Drag files here*")
# Initialize chat history in session state
if "messages" not in st.session_state:
st.session_state.messages = []
# Display chat history
st.markdown("### Chat History")
for message in st.session_state.messages:
with st.chat_message(message["role"]):
st.markdown(message["content"])
# Chat input
if prompt := st.chat_input("Enter your message..."):
# Add user message to chat history
st.session_state.messages.append({"role": "user", "content": prompt})
# Display user message
with st.chat_message("user"):
st.markdown(prompt)
# Example response (you can modify this based on your needs)
response = "I received your message: " + prompt
# Display assistant response
with st.chat_message("assistant"):
st.markdown(response)
# Add assistant response to chat history
st.session_state.messages.append({"role": "assistant", "content": response})
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?