import streamlit as st from bot2 import load_data, rag_bot # Streamlit app setup st.set_page_config(page_title="TravelGPT", page_icon="🍁", layout="wide") # Load data @st.cache_resource def load_combined_df(): return load_data() combined_df = load_combined_df() st.title("TrueNorthTraveler: Your Travel Assistant 🍁🏔️") st.markdown(""" Welcome to TNT-GPT, your friendly travel assistant! Your true guide to explore the Great White North!! Enter your travel preferences below, and we'll recommend the best hotels and attractions just for you. """) # Initialize chat history if 'chat_history' not in st.session_state: st.session_state.chat_history = [] # Sidebar for chat history # st.sidebar.title("Chat History") # for i, chat in enumerate(st.session_state.chat_history): # st.sidebar.markdown(f"**Query {i+1}:** {chat['query']}") # st.sidebar.markdown(f"**Response {i+1}:** {chat['response']}") # Sidebar for chat history st.sidebar.title("Chat History") for i, chat in enumerate(st.session_state.chat_history): with st.sidebar.expander(f"Query {i+1}"): st.markdown(f"**Query:** {chat['query']}") st.markdown(f"**Response:** {chat['response']}") # Input section query = st.text_input("Enter your travel query:", placeholder="e.g., I'm looking for a pet-friendly hotel in Ontario in a price range of $ 100-300.") button_col, result_col = st.columns([1, 3]) if button_col.button("Get Recommendations"): if query: with st.spinner('Processing...'): try: response, st.session_state.chat_history = rag_bot(query, combined_df, st.session_state.chat_history) if response.strip(): result_col.markdown("### Recommendations") result_col.write(response) else: result_col.write("No recommendations found for your query. Please try a different query.") except Exception as e: result_col.error(f"An error occurred: {e}") else: result_col.warning("Please enter a query to get recommendations.")