File size: 2,109 Bytes
55ae5c9
 
 
 
fda234d
55ae5c9
 
 
 
 
 
 
 
d140e5a
55ae5c9
d140e5a
 
55ae5c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d140e5a
55ae5c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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.")