|
import streamlit as st |
|
from bot2 import load_data, rag_bot |
|
|
|
|
|
st.set_page_config(page_title="TravelGPT", page_icon="π", layout="wide") |
|
|
|
|
|
@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. |
|
""") |
|
|
|
|
|
if 'chat_history' not in st.session_state: |
|
st.session_state.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']}") |
|
|
|
|
|
|
|
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.") |
|
|