QAway-to commited on
Commit
cf62ab3
·
1 Parent(s): dd7e39b

New version v2.0

Browse files
Files changed (1) hide show
  1. app.py +11 -22
app.py CHANGED
@@ -31,9 +31,10 @@ def classify_and_ask(user_input, question_count):
31
  with concurrent.futures.ThreadPoolExecutor() as executor:
32
  future_analysis = executor.submit(lambda: analyzer(user_input))
33
  future_question = executor.submit(lambda: q_gen(
34
- f"You are a friendly HR interviewer for an MBTI test. "
35
- f"Generate ONE open-ended and meaningful question starting with 'How', 'Why', 'What', or 'When'. "
36
- f"Do NOT repeat or refer to previous answers.\nUser said: {user_input}\n"
 
37
  ))
38
 
39
  analysis_result = future_analysis.result()
@@ -48,7 +49,6 @@ def classify_and_ask(user_input, question_count):
48
  raw = question_result[0]["generated_text"].replace("\n", " ").strip()
49
  question = raw.split("?")[0].split("Question:")[-1].strip().capitalize() + "?"
50
 
51
- # Инкрементируем счётчик
52
  question_count += 1
53
  progress = f"{question_count}/30"
54
 
@@ -56,19 +56,7 @@ def classify_and_ask(user_input, question_count):
56
 
57
 
58
  # =========================================================
59
- # 3. Функция для первого вопроса при старте
60
- # =========================================================
61
- def generate_first_question():
62
- result = q_gen(
63
- "You are starting an MBTI interview. Ask the FIRST open-ended question "
64
- "to understand the person’s personality, starting with 'How', 'Why', 'What', or 'When'."
65
- )[0]["generated_text"]
66
- question = result.split("?")[0].split("Question:")[-1].strip().capitalize() + "?"
67
- return question, "1/30"
68
-
69
-
70
- # =========================================================
71
- # 4. Интерфейс Gradio
72
  # =========================================================
73
  with gr.Blocks(title="MBTI Interactive Interview") as demo:
74
  gr.Markdown("## 🧠 MBTI Personality Interviewer\n"
@@ -88,7 +76,11 @@ with gr.Blocks(title="MBTI Interactive Interview") as demo:
88
 
89
  with gr.Column(scale=1):
90
  out_analysis = gr.Textbox(label="📊 Анализ MBTI", lines=6)
91
- out_question = gr.Textbox(label="💬 Следующий вопрос от интервьюера", lines=3)
 
 
 
 
92
 
93
  btn.click(
94
  fn=classify_and_ask,
@@ -96,11 +88,8 @@ with gr.Blocks(title="MBTI Interactive Interview") as demo:
96
  outputs=[out_analysis, out_question, progress],
97
  )
98
 
99
- # генерируем первый вопрос при запуске
100
- demo.load(generate_first_question, outputs=[out_question, progress])
101
-
102
  # =========================================================
103
- # 5. Запуск
104
  # =========================================================
105
  if __name__ == "__main__":
106
  demo.launch()
 
31
  with concurrent.futures.ThreadPoolExecutor() as executor:
32
  future_analysis = executor.submit(lambda: analyzer(user_input))
33
  future_question = executor.submit(lambda: q_gen(
34
+ f"You are a professional MBTI interviewer. "
35
+ f"Generate ONE open-ended question starting with 'How', 'Why', 'What', or 'When'. "
36
+ f"Ask something new to reveal personality traits, not repeating or referencing prior answers. "
37
+ f"User's latest answer: {user_input}"
38
  ))
39
 
40
  analysis_result = future_analysis.result()
 
49
  raw = question_result[0]["generated_text"].replace("\n", " ").strip()
50
  question = raw.split("?")[0].split("Question:")[-1].strip().capitalize() + "?"
51
 
 
52
  question_count += 1
53
  progress = f"{question_count}/30"
54
 
 
56
 
57
 
58
  # =========================================================
59
+ # 3. Интерфейс Gradio
 
 
 
 
 
 
 
 
 
 
 
 
60
  # =========================================================
61
  with gr.Blocks(title="MBTI Interactive Interview") as demo:
62
  gr.Markdown("## 🧠 MBTI Personality Interviewer\n"
 
76
 
77
  with gr.Column(scale=1):
78
  out_analysis = gr.Textbox(label="📊 Анализ MBTI", lines=6)
79
+ out_question = gr.Textbox(
80
+ label="💬 Вопрос от интервьюера",
81
+ value="How do you usually spend your free time?",
82
+ lines=3
83
+ )
84
 
85
  btn.click(
86
  fn=classify_and_ask,
 
88
  outputs=[out_analysis, out_question, progress],
89
  )
90
 
 
 
 
91
  # =========================================================
92
+ # 4. Запуск
93
  # =========================================================
94
  if __name__ == "__main__":
95
  demo.launch()