Sephfox commited on
Commit
f02e70c
·
verified ·
1 Parent(s): 4daafb8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -21
app.py CHANGED
@@ -254,7 +254,6 @@ def visualize_emotions():
254
  plt.close()
255
 
256
  return 'emotional_state.png'
257
-
258
  def interactive_interface(input_text):
259
  global conversation_history
260
  try:
@@ -288,28 +287,26 @@ def interactive_interface(input_text):
288
 
289
  emotion_visualization = visualize_emotions()
290
 
291
- analysis_result = {
292
- 'predicted_user_emotion': predicted_emotion,
293
- 'ai_emotion': ai_emotion,
294
- 'sentiment_scores': sentiment_scores,
295
- 'entities': entities,
296
- 'text_complexity': text_complexity,
297
- 'response': response,
298
- 'emotion_visualization': emotion_visualization
299
- }
300
-
301
- return analysis_result
302
  except Exception as e:
303
  print(f"Error: {e}")
304
- return {
305
- 'predicted_user_emotion': 'unknown',
306
- 'ai_emotion': 'neutral',
307
- 'sentiment_scores': {'compound': 0, 'neg': 0, 'neu': 1, 'pos': 0},
308
- 'entities': [],
309
- 'text_complexity': {'word_count': 0, 'sentence_count': 0, 'average_sentence_length': 0, 'polarity': 0, 'subjectivity': 0},
310
- 'response': "I'm sorry, but I encountered an error and was unable to generate a response.",
311
- 'emotion_visualization': 'emotional_state.png'
312
- }
313
 
314
  # Create a Gradio interface
315
  gr.Interface(
 
254
  plt.close()
255
 
256
  return 'emotional_state.png'
 
257
  def interactive_interface(input_text):
258
  global conversation_history
259
  try:
 
287
 
288
  emotion_visualization = visualize_emotions()
289
 
290
+ return (
291
+ predicted_emotion,
292
+ ai_emotion,
293
+ str(sentiment_scores),
294
+ str(entities),
295
+ str(text_complexity),
296
+ response,
297
+ emotion_visualization
298
+ )
 
 
299
  except Exception as e:
300
  print(f"Error: {e}")
301
+ return (
302
+ 'unknown',
303
+ 'neutral',
304
+ str({'compound': 0, 'neg': 0, 'neu': 1, 'pos': 0}),
305
+ '[]',
306
+ str({'word_count': 0, 'sentence_count': 0, 'average_sentence_length': 0, 'polarity': 0, 'subjectivity': 0}),
307
+ "I'm sorry, but I encountered an error and was unable to generate a response.",
308
+ 'emotional_state.png'
309
+ )
310
 
311
  # Create a Gradio interface
312
  gr.Interface(