put the submit button before the chatbot window with color #ae1c93 , also nearby…
- User
put the submit button before the chatbot window with color #ae1c93 , also nearby Professionals Make them nearby Health Professionals and show that in a tabular form + map is already there. Make the Background color to be : #3c6487 import os import gradio as gr import nltk import numpy as np import tflearn import random import json import pickle from nltk.tokenize import word_tokenize from nltk.stem.lancaster import LancasterStemmer from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline import googlemaps import folium import torch
Suppress TensorFlow warnings
os.environ["CUDA_VISIBLE_DEVICES"] = "-1" os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
Download necessary NLTK resources
nltk.download("punkt") stemmer = LancasterStemmer()
Load intents and chatbot training data
with open("intents.json") as file: intents_data = json.load(file)
with open("data.pickle", "rb") as f: words, labels, training, output = pickle.load(f)
Build the chatbot model
net = tflearn.input_data(shape=[None, len(training[0])]) net = tflearn.fully_connected(net, 8) net = tflearn.fully_connected(net, 8) net = tflearn.fully_connected(net, len(output[0]), activation="softmax") net = tflearn.regression(net) chatbot_model = tflearn.DNN(net) chatbot_model.load("MentalHealthChatBotmodel.tflearn")
Hugging Face sentiment and emotion models
tokenizer_sentiment = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment") model_sentiment = AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment") tokenizer_emotion = AutoTokenizer.from_pretrained("j-hartmann/emotion-english-distilroberta-base") model_emotion = AutoModelForSequenceClassification.from_pretrained("j-hartmann/emotion-english-distilroberta-base")
Google Maps API Client
gmaps = googlemaps.Client(key=os.getenv("GOOGLE_API_KEY"))
Helper Functions
def bag_of_words(s, words): """Convert user input to bag-of-words vector.""" bag = [0] * len(words) s_words = word_tokenize(s) s_words = [stemmer.stem(word.lower()) for word in s_words if word.isalnum()] for se in s_words: for i, w in enumerate(words): if w == se: bag[i] = 1 return np.array(bag)
def generate_chatbot_response(message, history): """Generate chatbot response and maintain conversation history.""" history = history or [] try: result = chatbot_model.predict([bag_of_words(message, words)]) tag = labels[np.argmax(result)] response = "I'm sorry, I didn't understand that. 🤔" for intent in intents_data["intents"]: if intent["tag"] == tag: response = random.choice(intent["responses"]) break except Exception as e: response = f"Error: {e}" history.append((message, response)) return history, response
def analyze_sentiment(user_input): """Analyze sentiment and map to emojis.""" inputs = tokenizer_sentiment(user_input, return_tensors="pt") with torch.no_grad(): outputs = model_sentiment(**inputs) sentiment_class = torch.argmax(outputs.logits, dim=1).item() sentiment_map = ["Negative 😔", "Neutral 😐", "Positive 😊"] return f"Sentiment: {sentiment_map[sentiment_class]}"
- Assistant
- User
now share the full updated code
- Assistant
- User
The Nearby health professionals text Box should show everything in a tabular format
- Assistant
- User
Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/gradio/queueing.py", line 624, in process_events response = await route_utils.call_process_api( File "/usr/local/lib/python3.10/site-packages/gradio/route_utils.py", line 323, in call_process_api output = await app.get_blocks().process_api( File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 2025, in process_api data = await self.postprocess_data(block_fn, result["prediction"], state) File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 1831, in postprocess_data prediction_value = block.postprocess(prediction_value) File "/usr/local/lib/python3.10/site-packages/gradio/components/dataframe.py", line 316, in postprocess return DataframeData(headers=_headers, data=value) File "/usr/local/lib/python3.10/site-packages/pydantic/main.py", line 214, in init validated_self = self.pydantic_validator.validate_python(data, self_instance=self) pydantic_core._pydantic_core.ValidationError: 2 validation errors for DataframeData data.list[list[any]].0 Input should be a valid list [type=list_type, input_value='Please provide both location and query.', input_type=str] For further information visit data..0 Input should be a valid tuple [type=tuple_type, input_value='Please provide both location and query.', input_type=str] For further information visit fix it and share the full updated code
- Assistant
- User
make the submit button color to be : ae1c93 and then share full updated code without missing anything.
- Assistant
- User
Make the suggestions table with clickable direct links , do not skip anything and then share the full updated code
- Assistant
- User
can we make it important to apply ? #suggestions-title { text-align: center; font-weight: bold; color: white; font-size: 4.2rem; margin-bottom: 20px; }
- Assistant
- User
Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/gradio/queueing.py", line 624, in process_events response = await route_utils.call_process_api( File "/usr/local/lib/python3.10/site-packages/gradio/route_utils.py", line 323, in call_process_api output = await app.get_blocks().process_api( File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 2025, in process_api data = await self.postprocess_data(block_fn, result["prediction"], state) File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 1831, in postprocess_data prediction_value = block.postprocess(prediction_value) File "/usr/local/lib/python3.10/site-packages/gradio/components/dataframe.py", line 316, in postprocess return DataframeData(headers=_headers, data=value) File "/usr/local/lib/python3.10/site-packages/pydantic/main.py", line 214, in validated_self = self..validate_python(data, self_instance=self) pydantic_core._pydantic_core.ValidationError: 6 validation errors for DataframeData data.list[list[any]].0 Input should be a valid list [type=list_type, input_value={'Title': 'Emotional Well...ional-wellness-toolkit'}, input_type=dict] For further information visit data.list[list[any]].1 Input should be a valid list [type=list_type, input_value={'Title': 'Dealing with A...r-dealing-with-anxiety'}, input_type=dict] For further information visit data.list[list[any]].2 Input should be a valid list [type=list_type, input_value={'Title': 'Relaxation Vid...//youtu.be/-e-4Kx5px_I'}, input_type=dict] For further information visit data..0 Input should be a valid tuple [type=tuple_type, input_value={'Title': 'Emotional Well...ional-wellness-toolkit'}, input_type=dict] For further information visit data..1 Input should be a valid tuple [type=tuple_type, input_value={'Title': 'Dealing with A...r-dealing-with-anxiety'}, input_type=dict] For further information visit data..2 Input should be a valid tuple [type=tuple_type, input_value={'Title': 'Relaxation Vid...//youtu.be/-e-4Kx5px_I'}, input_type=dict] For further information visit do not repeat this error again fix it and share the full updated code.
- Assistant
- User
- Assistant
- User
can we make these kinds of links cilckable https://www.helpguide.org/mental-health/anxiety/tips-for-dealing-with-anxiety ? on gradio interface on hugging face space
- Assistant