File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -502,6 +502,11 @@ async def is_chat_required(employee_id: str) -> bool:
502502 {"Employee_ID" : employee_id },
503503 sort = [("timestamp" , - 1 )]
504504 )
505+
506+ latest_vibe = await async_db ["vibemeter" ].find_one (
507+ {"employee_id" : employee_id },
508+ sort = [("timestamp" , - 1 )]
509+ )
505510
506511 if not latest_analysis :
507512 logger .info (f"No analyzed profile found for { employee_id } . Chat required." )
@@ -522,14 +527,14 @@ async def is_chat_required(employee_id: str) -> bool:
522527
523528 # Check predicted score and emotions
524529 predicted_score = latest_analysis .get ("Predicted" , 0 )
525- actual_emotion = latest_analysis .get ("Actual_Emotion " , "unknown" )
530+ actual_emotion = latest_vibe .get ("Vibe_Score " , 0 )
526531
527532 # If predicted score is low or emotions indicate distress
528533 if predicted_score <= 2.5 :
529534 logger .info (f"Low predicted score ({ predicted_score } ) for { employee_id } . Chat required." )
530535 return True
531536
532- if actual_emotion in [ "Sad" , "Frustrated" ] :
537+ if actual_emotion <= 2 :
533538 logger .info (f"Concerning emotion state ({ actual_emotion } ) for { employee_id } . Chat required." )
534539 return True
535540
You can’t perform that action at this time.
0 commit comments