Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -88,7 +88,29 @@ def respond(message, chat_history, user_profile):
|
|
| 88 |
return chat_history
|
| 89 |
|
| 90 |
# If interview is ongoing
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
if user_profile.get("questions"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
q_index = user_profile['current_q']
|
| 93 |
user_profile['user_answers'].append(message)
|
| 94 |
|
|
@@ -99,8 +121,10 @@ def respond(message, chat_history, user_profile):
|
|
| 99 |
bot_msg = f"Next question: {user_profile['questions'][q_index]['question']}"
|
| 100 |
else:
|
| 101 |
bot_msg = "Interview complete! Type 'feedback' if you'd like me to analyze your answers."
|
|
|
|
| 102 |
chat_history.append((message, bot_msg))
|
| 103 |
return chat_history
|
|
|
|
| 104 |
|
| 105 |
# Handle feedback request
|
| 106 |
if message.strip().lower() == 'feedback':
|
|
|
|
| 88 |
return chat_history
|
| 89 |
|
| 90 |
# If interview is ongoing
|
| 91 |
+
# if user_profile.get("questions"):
|
| 92 |
+
# q_index = user_profile['current_q']
|
| 93 |
+
# user_profile['user_answers'].append(message)
|
| 94 |
+
|
| 95 |
+
# q_index += 1
|
| 96 |
+
# user_profile['current_q'] = q_index
|
| 97 |
+
|
| 98 |
+
# if q_index < len(user_profile['questions']):
|
| 99 |
+
# bot_msg = f"Next question: {user_profile['questions'][q_index]['question']}"
|
| 100 |
+
# else:
|
| 101 |
+
# bot_msg = "Interview complete! Type 'feedback' if you'd like me to analyze your answers."
|
| 102 |
+
# chat_history.append((message, bot_msg))
|
| 103 |
+
# return chat_history
|
| 104 |
if user_profile.get("questions"):
|
| 105 |
+
|
| 106 |
+
# --- NEW STOP LOGIC ---
|
| 107 |
+
if message.strip().lower() == 'stop':
|
| 108 |
+
bot_msg = "Thank you for chatting with Intervu! The interview has been stopped. Type 'feedback' if you'd like me to analyze your answers."
|
| 109 |
+
chat_history.append((message, bot_msg))
|
| 110 |
+
user_profile['questions'] = [] # clear questions list to stop
|
| 111 |
+
return chat_history
|
| 112 |
+
|
| 113 |
+
# Existing interview logic continues here:
|
| 114 |
q_index = user_profile['current_q']
|
| 115 |
user_profile['user_answers'].append(message)
|
| 116 |
|
|
|
|
| 121 |
bot_msg = f"Next question: {user_profile['questions'][q_index]['question']}"
|
| 122 |
else:
|
| 123 |
bot_msg = "Interview complete! Type 'feedback' if you'd like me to analyze your answers."
|
| 124 |
+
|
| 125 |
chat_history.append((message, bot_msg))
|
| 126 |
return chat_history
|
| 127 |
+
|
| 128 |
|
| 129 |
# Handle feedback request
|
| 130 |
if message.strip().lower() == 'feedback':
|