Basitha commited on
Commit
4156168
·
verified ·
1 Parent(s): 4d7a0de

Update researchsimulation/InteractiveInterviewChatbot.py

Browse files
researchsimulation/InteractiveInterviewChatbot.py CHANGED
@@ -413,20 +413,22 @@ def validate_generic_answer(agent_name, agent_question, generic_answer, user_pro
413
  logging.exception("[validate_generic_answer] Exception during validation")
414
  return False
415
 
416
- def validate_styled_answer(agent_name, agent_question, styled_answer, user_profile, processor_llm):
 
 
 
 
417
  logging.info("[validate_styled_answer] Entry")
418
  try:
419
- is_valid = validate_response(
420
- question=agent_question,
421
  answer=styled_answer,
422
- user_profile_str=str(user_profile),
423
- fast_facts_str="",
424
- interview_transcript_text="",
425
- respondent_type=agent_name,
426
- ai_evaluator_agent=None,
427
- processor_llm=processor_llm
428
  )
429
- logging.info(f"[validate_styled_answer] Result: {is_valid}")
430
  return is_valid
431
  except Exception as e:
432
  logging.exception("[validate_styled_answer] Exception during style validation")
@@ -477,7 +479,7 @@ def ask_interview_question(respondent_agents_dict, last_active_agent, question,
477
  generic_answer = generate_generic_answer(agent_name, agent_question, respondent_agent)
478
 
479
  if not validate_generic_answer(agent_name, agent_question, generic_answer, user_profile, processor_llm):
480
- responses.append(f"**PreData Moderator**: The generated answer for {agent_name} did not meet our content standards.")
481
  continue
482
 
483
  def generator():
 
413
  logging.exception("[validate_generic_answer] Exception during validation")
414
  return False
415
 
416
+ def validate_styled_answer(agent_name, agent_question, styled_answer, user_profile, processor_llm, interview_transcript_text):
417
+ """
418
+ Validates whether the styled answer matches the user's typical speaking style using prior interview transcript and communication profile.
419
+ Returns True if stylistically aligned, False otherwise.
420
+ """
421
  logging.info("[validate_styled_answer] Entry")
422
  try:
423
+ # Use transcript-based style matching logic
424
+ is_valid = matches_user_speaking_style(
425
  answer=styled_answer,
426
+ transcript_text=interview_transcript_text,
427
+ processor_llm=processor_llm,
428
+ user_profile=user_profile,
429
+ agent_question=agent_question
 
 
430
  )
431
+ logging.info(f"[validate_styled_answer] Style validation result: {is_valid}")
432
  return is_valid
433
  except Exception as e:
434
  logging.exception("[validate_styled_answer] Exception during style validation")
 
479
  generic_answer = generate_generic_answer(agent_name, agent_question, respondent_agent)
480
 
481
  if not validate_generic_answer(agent_name, agent_question, generic_answer, user_profile, processor_llm):
482
+ responses.append(f"**PreData Moderator**: Please ask {agent_name} again.")
483
  continue
484
 
485
  def generator():