DreamStream-1 commited on
Commit
456391b
·
verified ·
1 Parent(s): 4525308

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -22
app.py CHANGED
@@ -11,13 +11,6 @@ from nltk.stem.lancaster import LancasterStemmer
11
  from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
12
  import requests
13
  import pandas as pd
14
- from selenium import webdriver
15
- from selenium.webdriver.chrome.options import Options
16
- import chromedriver_autoinstaller
17
- import os
18
- import time
19
- import re
20
- from bs4 import BeautifulSoup
21
 
22
  # Ensure necessary NLTK resources are downloaded
23
  nltk.download('punkt')
@@ -37,7 +30,7 @@ try:
37
  with open("data.pickle", "rb") as f:
38
  words, labels, training, output = pickle.load(f)
39
  except FileNotFoundError:
40
- raise FileNotFoundError("Error: 'data.pickle' file not found in the app directory.")
41
 
42
  # Build the model structure
43
  net = tflearn.input_data(shape=[None, len(training[0])])
@@ -157,7 +150,7 @@ def provide_suggestions(emotion):
157
  return suggestions
158
 
159
  # Google Places API to get nearby wellness professionals
160
- api_key = "GOOGLE_API_KEY" # Replace with your API key
161
 
162
  def get_places_data(query, location, radius, api_key, next_page_token=None):
163
  url = "https://maps.googleapis.com/maps/api/place/textsearch/json"
@@ -227,21 +220,21 @@ iface = gr.Interface(
227
  fn=gradio_interface,
228
  inputs=[
229
  gr.Textbox(label="Enter your message", placeholder="How are you feeling today?"),
230
- gr.Textbox(label="Enter your location (e.g., Hawaii, Oahu)", placeholder="Your location"),
231
- gr.State() # One state input
232
  ],
233
  outputs=[
234
- gr.Chatbot(label="Chatbot History"),
235
- gr.Textbox(label="Sentiment"),
236
- gr.Textbox(label="Emotion"),
237
- gr.Dataframe(label="Wellness Professionals"),
238
- gr.State() # State output (maintains conversation history)
 
239
  ],
240
- title="Mental Health Chatbot",
241
- description="This chatbot helps with mental health inquiries and provides suggestions for wellness professionals.",
242
- live=True
243
  )
244
 
245
- # Run the interface
246
- if __name__ == "__main__":
247
- iface.launch(debug=True)
 
11
  from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
12
  import requests
13
  import pandas as pd
 
 
 
 
 
 
 
14
 
15
  # Ensure necessary NLTK resources are downloaded
16
  nltk.download('punkt')
 
30
  with open("data.pickle", "rb") as f:
31
  words, labels, training, output = pickle.load(f)
32
  except FileNotFoundError:
33
+ raise FileNotFoundError("Error: 'data.pickle' file not found. Ensure it exists and matches the model.")
34
 
35
  # Build the model structure
36
  net = tflearn.input_data(shape=[None, len(training[0])])
 
150
  return suggestions
151
 
152
  # Google Places API to get nearby wellness professionals
153
+ api_key = "YOUR_GOOGLE_API_KEY" # Replace with your actual Google API key
154
 
155
  def get_places_data(query, location, radius, api_key, next_page_token=None):
156
  url = "https://maps.googleapis.com/maps/api/place/textsearch/json"
 
220
  fn=gradio_interface,
221
  inputs=[
222
  gr.Textbox(label="Enter your message", placeholder="How are you feeling today?"),
223
+ gr.Textbox(label="Enter your location (e.g., 'Hawaii, USA')", placeholder="Enter your location"),
224
+ gr.State() # To maintain state (chat history)
225
  ],
226
  outputs=[
227
+ gr.Chatbot(label="Chatbot Responses"),
228
+ gr.Textbox(label="Sentiment Analysis"),
229
+ gr.Textbox(label="Emotion Detected"),
230
+ gr.DataFrame(label="Suggested Articles & Videos"),
231
+ gr.DataFrame(label="Nearby Wellness Professionals"),
232
+ gr.State() # To maintain state (chat history)
233
  ],
234
+ live=True,
235
+ title="Mental Health Chatbot with Wellness Professional Search",
236
+ description="This chatbot provides mental health support with sentiment analysis, emotion detection, suggestions, and a list of nearby wellness professionals."
237
  )
238
 
239
+ # Launch the interface
240
+ iface.launch(debug=True, share=True)