Katon1 commited on
Commit
25a5b01
verified
1 Parent(s): 6435f99

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -39,10 +39,11 @@ class ModelHandler:
39
 
40
  def analyze_emotion(self, input_text):
41
  # Analiza la emoci贸n del texto proporcionado
42
- client = InferenceClient("microsoft/xtremedistil-l6-h384-uncased", token=hf_token)
43
  try:
44
- response = client.sentiment(input_text)
45
- return response
 
 
46
  except Exception as e:
47
  return f"Error al analizar la emoci贸n: {e}"
48
 
@@ -116,7 +117,7 @@ with gr.Blocks(title="Multi-Model LLM Chatbot with Image Generation and Emotion
116
  return last_status, last_image
117
  elif selected_action == "An谩lisis de Emociones":
118
  emotion_result = model_handler.analyze_emotion(user_input)
119
- return f"Emoci贸n detectada: {emotion_result}", None
120
  else:
121
  model_handler.switch_model(selected_action)
122
  response = model_handler.generate_response(user_input)
 
39
 
40
  def analyze_emotion(self, input_text):
41
  # Analiza la emoci贸n del texto proporcionado
 
42
  try:
43
+ client = InferenceClient("bhadresh-savani/distilbert-base-uncased-emotion", token=hf_token)
44
+ response = client.text_classification(input_text)
45
+ emotions = [f"{label['label']}: {label['score']:.2f}" for label in response]
46
+ return "\n".join(emotions)
47
  except Exception as e:
48
  return f"Error al analizar la emoci贸n: {e}"
49
 
 
117
  return last_status, last_image
118
  elif selected_action == "An谩lisis de Emociones":
119
  emotion_result = model_handler.analyze_emotion(user_input)
120
+ return f"Emoci贸n detectada:\n{emotion_result}", None
121
  else:
122
  model_handler.switch_model(selected_action)
123
  response = model_handler.generate_response(user_input)