AIMLdeepanshu commited on
Commit
5c0808b
·
verified ·
1 Parent(s): b68f858

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -5
app.py CHANGED
@@ -46,23 +46,33 @@ def save_user_info(name, user_field, voice):
46
  # -----------------------------
47
  def generate_questions():
48
  global field, interview_questions, current_question_index, feedback_summary
 
49
  current_question_index = 0
50
  feedback_summary = []
51
 
52
  prompt = (
53
- f"You are a professional interview panel. Generate 7 technical and 5 behavioral questions "
54
- f"for an internship interview in the field of {field}. Only list the questions in numbered format."
 
 
 
55
  )
56
  try:
57
  response = model.generate_content(prompt)
58
- lines = response.text.strip().split('\n')
59
- interview_questions = [line.strip() for line in lines if line.strip()]
 
 
 
 
60
  if len(interview_questions) != 12:
61
  return "⚠️ Gemini did not return exactly 12 questions. Please try again.", ""
62
- return "✅ Questions generated successfully!", interview_questions[0] # Start with first question
 
63
  except Exception as e:
64
  return f"Error: {str(e)}", ""
65
 
 
66
  # -----------------------------
67
  # ✅ STEP 3: Speak Current Question
68
  # -----------------------------
 
46
  # -----------------------------
47
  def generate_questions():
48
  global field, interview_questions, current_question_index, feedback_summary
49
+ import re
50
  current_question_index = 0
51
  feedback_summary = []
52
 
53
  prompt = (
54
+ f"You are a professional interview panel. Generate exactly 12 interview questions "
55
+ f"(7 technical and 5 behavioral) for an internship interview in the field of {field}.\n"
56
+ f"Return the output in the following strict format:\n"
57
+ f"1. <question one>\n2. <question two>\n... up to 12. <question twelve>\n"
58
+ f"No explanations or headings. Just the 12 numbered questions."
59
  )
60
  try:
61
  response = model.generate_content(prompt)
62
+ raw_output = response.text.strip()
63
+
64
+ # ✅ Extract lines that start with "1." to "12."
65
+ lines = re.findall(r"^\d+\.\s+.*", raw_output, re.MULTILINE)
66
+ interview_questions = [line.strip() for line in lines]
67
+
68
  if len(interview_questions) != 12:
69
  return "⚠️ Gemini did not return exactly 12 questions. Please try again.", ""
70
+
71
+ return "✅ Questions generated successfully!", interview_questions[0]
72
  except Exception as e:
73
  return f"Error: {str(e)}", ""
74
 
75
+
76
  # -----------------------------
77
  # ✅ STEP 3: Speak Current Question
78
  # -----------------------------