Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -179,36 +179,67 @@ css = """
|
|
| 179 |
background-color: #f7f7f7;
|
| 180 |
}
|
| 181 |
.gradio-input, .gradio-output {
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
| 183 |
}
|
| 184 |
-
.gradio-button {
|
| 185 |
-
background-color: #
|
| 186 |
color: white;
|
| 187 |
border-radius: 5px;
|
| 188 |
}
|
| 189 |
-
.gradio-button:hover {
|
| 190 |
-
background-color: #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
}
|
| 192 |
"""
|
| 193 |
|
| 194 |
-
# Gradio interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
iface = gr.Interface(
|
| 196 |
-
fn=
|
| 197 |
inputs=[
|
| 198 |
-
gr.Textbox(
|
| 199 |
-
gr.
|
|
|
|
|
|
|
| 200 |
],
|
| 201 |
outputs=[
|
| 202 |
-
gr.Chatbot(label="Chatbot History"),
|
| 203 |
gr.Textbox(label="Sentiment Analysis"),
|
| 204 |
-
gr.Textbox(label="Emotion
|
| 205 |
-
gr.
|
| 206 |
-
gr.
|
|
|
|
|
|
|
| 207 |
],
|
| 208 |
-
layout="vertical",
|
| 209 |
live=True,
|
| 210 |
-
|
|
|
|
|
|
|
| 211 |
)
|
| 212 |
|
| 213 |
-
# Launch
|
| 214 |
iface.launch(share=True)
|
|
|
|
| 179 |
background-color: #f7f7f7;
|
| 180 |
}
|
| 181 |
.gradio-input, .gradio-output {
|
| 182 |
+
padding: 10px;
|
| 183 |
+
border-radius: 5px;
|
| 184 |
+
background-color: #fff;
|
| 185 |
+
border: 1px solid #ccc;
|
| 186 |
}
|
| 187 |
+
.gradio-container .gradio-button {
|
| 188 |
+
background-color: #4CAF50;
|
| 189 |
color: white;
|
| 190 |
border-radius: 5px;
|
| 191 |
}
|
| 192 |
+
.gradio-container .gradio-button:hover {
|
| 193 |
+
background-color: #45a049;
|
| 194 |
+
}
|
| 195 |
+
.gradio-output {
|
| 196 |
+
font-size: 16px;
|
| 197 |
+
color: #333;
|
| 198 |
+
}
|
| 199 |
+
.gradio-container h3 {
|
| 200 |
+
color: #333;
|
| 201 |
+
}
|
| 202 |
+
.gradio-output .output {
|
| 203 |
+
border-top: 2px solid #ddd;
|
| 204 |
}
|
| 205 |
"""
|
| 206 |
|
| 207 |
+
# Gradio interface components
|
| 208 |
+
def gradio_app(message, current_location, health_professional_query, history):
|
| 209 |
+
# Detect sentiment and emotion
|
| 210 |
+
sentiment = analyze_sentiment(message)
|
| 211 |
+
emotion = detect_emotion(message)
|
| 212 |
+
|
| 213 |
+
# Generate suggestions based on emotion
|
| 214 |
+
suggestions_df = generate_suggestions(emotion)
|
| 215 |
+
|
| 216 |
+
# Get health professionals details and map
|
| 217 |
+
route_info, map_html = get_health_professionals_and_map(current_location, health_professional_query)
|
| 218 |
+
|
| 219 |
+
return sentiment, emotion, suggestions_df, route_info, map_html, history
|
| 220 |
+
|
| 221 |
+
# Gradio interface setup
|
| 222 |
iface = gr.Interface(
|
| 223 |
+
fn=gradio_app,
|
| 224 |
inputs=[
|
| 225 |
+
gr.Textbox(lines=2, placeholder="Enter your message..."),
|
| 226 |
+
gr.Textbox(lines=2, placeholder="Enter your current location..."),
|
| 227 |
+
gr.Textbox(lines=2, placeholder="Enter health professional query..."),
|
| 228 |
+
gr.State(value=[])
|
| 229 |
],
|
| 230 |
outputs=[
|
|
|
|
| 231 |
gr.Textbox(label="Sentiment Analysis"),
|
| 232 |
+
gr.Textbox(label="Detected Emotion"),
|
| 233 |
+
gr.Dataframe(label="Suggestions"),
|
| 234 |
+
gr.Textbox(label="Nearby Health Professionals"),
|
| 235 |
+
gr.HTML(label="Map of Health Professionals"),
|
| 236 |
+
gr.State(value=[])
|
| 237 |
],
|
|
|
|
| 238 |
live=True,
|
| 239 |
+
allow_flagging="never",
|
| 240 |
+
theme="huggingface",
|
| 241 |
+
css=css # Apply custom CSS styling
|
| 242 |
)
|
| 243 |
|
| 244 |
+
# Launch Gradio interface
|
| 245 |
iface.launch(share=True)
|