-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHealTrip-AI.py
More file actions
116 lines (96 loc) · 3.2 KB
/
HealTrip-AI.py
File metadata and controls
116 lines (96 loc) · 3.2 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import streamlit as st
import os
from dotenv import load_dotenv
from healtrip_chatbot_rag import run_healtrip_chatbot
from healtrip_chatbot_rag import start_vector_store
from healtrip_chatbot_rag import create_vector_store
load_dotenv()
# configure password
PASSWORD = os.environ["UI_PASS"]
st.set_page_config("Healtrip AI")
st.title("Welcome to Healtrip Chat Assistant! 👋")
hide_st_style = """
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
header {visibility: hidden;}
</style>
"""
st.markdown(hide_st_style, unsafe_allow_html=True)
password = st.experimental_get_query_params().get("pass", [""])[0]
if password != PASSWORD:
st.error("Oops! You seem to be in the wrong place. You are not authorized to view this page.")
st.stop()
st.markdown(
"""
This is QA Chat Assistant for Healtrip AI. You can ask anything related to Hospitals and Doctors in the Healtrip.
With this chat assistant you can plan your trip to the hospital, get information about the doctors, and much more.
"""
)
if st.sidebar.button("New chat :page_with_curl:"):
st.session_state.messages = []
st.session_state.messages = [
{
"role": "assistant",
"content": "Welcome to HealTrip AI - your personal Healtrip Assistant! 👋"
}
]
if st.sidebar.button("Get the latest version! :rocket:"):
st.session_state.messages = []
st.session_state.messages = [
{
"role": "assistant",
"content": "Welcome to HealTrip AI - your personal Healtrip Assistant! 👋"
}
]
st.write("Getting the latest version... ⏳")
created_db = create_vector_store("dhh_db")
st.write("The latest version has been created successfully! 🎉")
st.session_state.messages = []
st.session_state.messages = [
{
"role": "assistant",
"content": "Welcome to HealTrip AI - your personal Healtrip Assistant! 👋"
}
]
vector_db = start_vector_store("dhh_db")
# Initialize chat history
if "messages" not in st.session_state:
st.session_state.messages = [
{
"role":"assistant",
"content":"Welcome to HealTrip AI - your personal Healtrip Assistant! 👋"
}
]
# Display chat messages from history on app rerun
for message in st.session_state.messages:
with st.chat_message(message["role"]):
st.markdown(message["content"])
# Process and store Query and Response
def llm_function(query):
response = run_healtrip_chatbot(query, vector_db)
# Displaying the Assistant Message
with st.chat_message("assistant"):
st.markdown(response)
# Storing the User Message
st.session_state.messages.append(
{
"role":"user",
"content": query
}
)
# Storing the User Message
st.session_state.messages.append(
{
"role":"assistant",
"content": response
}
)
# Accept user input
query = st.chat_input("")
# Calling the Function when Input is Provided
if query:
# Displaying the User Message
with st.chat_message("user"):
st.markdown(query)
llm_function(query)