RagChatbot / app.py
sami606713's picture
Upload 17 files
27a8994 verified
raw
history blame contribute delete
956 Bytes
import streamlit as st
from agent.agent import RunAgent
# Set Streamlit layout
st.set_page_config(page_title="Document Chat App", layout="wide")
st.title("πŸ“„ Document Chat App")
# Initialize session state
if 'chat_history' not in st.session_state:
st.session_state.chat_history = []
# Display chat history
for speaker, message in st.session_state.chat_history:
with st.chat_message(name=speaker):
st.markdown(message)
# Chat input
user_input = st.chat_input("Ask something about your document...")
if user_input:
# Show user message
with st.chat_message("You"):
st.markdown(user_input)
# Run agent
response = RunAgent(query=user_input)
# Show bot response
with st.chat_message("Bot"):
st.markdown(response)
# Save to chat history
st.session_state.chat_history.append(("You", user_input))
st.session_state.chat_history.append(("Bot", response))