Spaces:
Sleeping
Sleeping
import os | |
import streamlit as st | |
from langchain_core.messages import AIMessage, HumanMessage | |
from utils import get_model_response | |
st.set_page_config(page_title="Yatra Sevak.AI βοΈ", page_icon="π", layout="wide") | |
st.title("Yatra Sevak.AI βοΈ") | |
st.caption("Planning a trip can be challenging these days. With so many choices for flights, hotels, and activities, travelers often find it difficult to pick the best options. Our Yatra Sevak.Ai chatbot is here to help. Imagine having a personal travel assistant at your fingertips someone who can book flights, find great hotels, recommend local attractions, and offer travel advice. Thanks to advanced AI, this is now possible.") | |
if "chat_history" not in st.session_state: | |
st.session_state.chat_history = [ | |
AIMessage(content="Hello, I am Yatra Sevak.AI How can I help you?"), | |
] | |
for message in st.session_state.chat_history: | |
if isinstance(message, AIMessage): | |
with st.chat_message("AI"): | |
st.write(message.content) | |
elif isinstance(message, HumanMessage): | |
with st.chat_message("Human"): | |
st.write(message.content) | |
user_query = st.chat_input("Type your message here....") | |
if user_query is not None and user_query != "": | |
st.session_state.chat_history.append(HumanMessage(content=user_query)) | |
with st.chat_message("Human"): | |
st.markdown(user_query) | |
with st.spinner('Yatra Sevak.AI is processing your query...'): | |
response = get_model_response(user_query, st.session_state.chat_history) | |
response = response.replace("AI response:", "").replace("chat response:", "").replace("bot response:", "").strip() | |
with st.chat_message("AI"): | |
st.write(response) | |
st.session_state.chat_history.append(AIMessage(content=response)) |