parthib07 commited on
Commit
c63bcf0
Β·
verified Β·
1 Parent(s): cc59299

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -11
app.py CHANGED
@@ -28,16 +28,13 @@ If the following pieces provide some information, combine it with your existing
28
  Include relevant details such as home remedies, medications, and other necessary actions in a clear, point-wise manner for quick readability.
29
  If any other related questions arise, just say, "I am a healthcare professional.How may i assist you today?"
30
  If you don't know the answer, just say that you don't know. Don't try to make up an answer.
31
-
32
  Context: {context}
33
  Question: {question}
34
-
35
  Only return the helpful answer below and nothing else.
36
  Helpful answer:
37
  """
38
 
39
  def generate_response(question):
40
-
41
  retriever = faiss_index.as_retriever(search_kwargs={'k': 1})
42
  docs = retriever.get_relevant_documents(question)
43
  context = "\n".join([doc.page_content for doc in docs])
@@ -53,13 +50,73 @@ def generate_response(question):
53
  return response.content
54
 
55
  st.set_page_config(page_title="HealthCare ChatBot", page_icon="πŸ€–", layout="centered")
56
- st.header("HealthCare ChatBot πŸ€–")
57
 
58
- user_input = st.text_input("Ask a Healthcare related question:", "")
59
- st.button("Generate Response")
60
- st.spinner('Processing')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
- if user_input:
63
- user_input = user_input.lower().strip()
64
- response = generate_response(user_input)
65
- st.write(f"Response: {response}")
 
 
 
28
  Include relevant details such as home remedies, medications, and other necessary actions in a clear, point-wise manner for quick readability.
29
  If any other related questions arise, just say, "I am a healthcare professional.How may i assist you today?"
30
  If you don't know the answer, just say that you don't know. Don't try to make up an answer.
 
31
  Context: {context}
32
  Question: {question}
 
33
  Only return the helpful answer below and nothing else.
34
  Helpful answer:
35
  """
36
 
37
  def generate_response(question):
 
38
  retriever = faiss_index.as_retriever(search_kwargs={'k': 1})
39
  docs = retriever.get_relevant_documents(question)
40
  context = "\n".join([doc.page_content for doc in docs])
 
50
  return response.content
51
 
52
  st.set_page_config(page_title="HealthCare ChatBot", page_icon="πŸ€–", layout="centered")
 
53
 
54
+ st.markdown("""
55
+ <style>
56
+ body {
57
+ background: linear-gradient(135deg, #E3F2FD 0%, #F3E5F5 100%);
58
+ font-family: 'Poppins', sans-serif;
59
+ }
60
+ .main-title {
61
+ text-align: center;
62
+ font-size: 38px;
63
+ font-weight: 700;
64
+ color: #2C3E50;
65
+ margin-top: 10px;
66
+ }
67
+ .sub-title {
68
+ text-align: center;
69
+ font-size: 16px;
70
+ color: #5D6D7E;
71
+ margin-bottom: 30px;
72
+ }
73
+ .stTextInput > div > div > input {
74
+ border: 2px solid #9C27B0;
75
+ border-radius: 12px;
76
+ padding: 10px;
77
+ }
78
+ .response-box {
79
+ background-color: #FFFFFF;
80
+ padding: 20px;
81
+ border-radius: 15px;
82
+ box-shadow: 0px 2px 10px rgba(0,0,0,0.1);
83
+ color: #333333;
84
+ line-height: 1.6;
85
+ }
86
+ .footer {
87
+ text-align: center;
88
+ font-size: 13px;
89
+ color: #777;
90
+ margin-top: 40px;
91
+ }
92
+ .stButton>button {
93
+ background: linear-gradient(90deg, #6A1B9A, #8E24AA);
94
+ color: white;
95
+ border-radius: 10px;
96
+ font-weight: 600;
97
+ padding: 0.6rem 1.2rem;
98
+ border: none;
99
+ transition: 0.3s;
100
+ }
101
+ .stButton>button:hover {
102
+ background: linear-gradient(90deg, #8E24AA, #AB47BC);
103
+ transform: scale(1.05);
104
+ }
105
+ </style>
106
+ """, unsafe_allow_html=True)
107
+
108
+ st.markdown('<div class="main-title">🩺 HealthCare ChatBot</div>', unsafe_allow_html=True)
109
+ st.markdown('<div class="sub-title">An AI-powered health assistant</div>', unsafe_allow_html=True)
110
+
111
+ user_input = st.text_input("πŸ’¬ Ask a healthcare-related question below:", "")
112
+
113
+ col1, col2, col3 = st.columns([1, 2, 1])
114
+ with col2:
115
+ generate_clicked = st.button("πŸš€ Generate Response")
116
 
117
+ if generate_clicked and user_input:
118
+ with st.spinner('πŸ” Analyzing your question...'):
119
+ response = generate_response(user_input.lower().strip())
120
+ st.markdown('<div class="response-box">', unsafe_allow_html=True)
121
+ st.write(f"**Response:** {response}")
122
+ st.markdown('</div>', unsafe_allow_html=True)