Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,7 @@ from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipe
|
|
| 12 |
import googlemaps
|
| 13 |
import folium
|
| 14 |
import os
|
|
|
|
| 15 |
|
| 16 |
# Ensure necessary NLTK resources are downloaded
|
| 17 |
nltk.download('punkt')
|
|
@@ -142,7 +143,7 @@ def get_health_professionals_and_map(current_location, health_professional_query
|
|
| 142 |
return route_info, m._repr_html_()
|
| 143 |
|
| 144 |
# Gradio interface
|
| 145 |
-
def gradio_app(message, location, health_query, history):
|
| 146 |
# Chatbot interaction
|
| 147 |
history, _ = chatbot(message, history)
|
| 148 |
|
|
@@ -173,11 +174,11 @@ map_output = gr.HTML(label="Map with Health Professionals")
|
|
| 173 |
# Create Gradio interface
|
| 174 |
iface = gr.Interface(
|
| 175 |
fn=gradio_app,
|
| 176 |
-
inputs=[message_input, location_input, health_query_input,
|
| 177 |
outputs=[chat_history, sentiment_output, emotion_output, route_info_output, map_output],
|
| 178 |
allow_flagging="never",
|
| 179 |
live=True,
|
| 180 |
title="Wellbeing App: Mental Health, Sentiment, Emotion Detection & Health Professional Search"
|
| 181 |
)
|
| 182 |
|
| 183 |
-
iface.launch()
|
|
|
|
| 12 |
import googlemaps
|
| 13 |
import folium
|
| 14 |
import os
|
| 15 |
+
import torch # Add this for sentiment analysis
|
| 16 |
|
| 17 |
# Ensure necessary NLTK resources are downloaded
|
| 18 |
nltk.download('punkt')
|
|
|
|
| 143 |
return route_info, m._repr_html_()
|
| 144 |
|
| 145 |
# Gradio interface
|
| 146 |
+
def gradio_app(message, location, health_query, history, state):
|
| 147 |
# Chatbot interaction
|
| 148 |
history, _ = chatbot(message, history)
|
| 149 |
|
|
|
|
| 174 |
# Create Gradio interface
|
| 175 |
iface = gr.Interface(
|
| 176 |
fn=gradio_app,
|
| 177 |
+
inputs=[message_input, location_input, health_query_input, gr.State()], # Updated state input
|
| 178 |
outputs=[chat_history, sentiment_output, emotion_output, route_info_output, map_output],
|
| 179 |
allow_flagging="never",
|
| 180 |
live=True,
|
| 181 |
title="Wellbeing App: Mental Health, Sentiment, Emotion Detection & Health Professional Search"
|
| 182 |
)
|
| 183 |
|
| 184 |
+
iface.launch()
|