Update app.py (#2)
Browse files- Update app.py (708c0e97bf0d2bba10aecd9dd27559eea62ede63)
app.py
CHANGED
@@ -152,6 +152,23 @@ def evaluate_answer(question, user_answer):
|
|
152 |
|
153 |
return response
|
154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
# Initialize session state
|
156 |
if 'questions' not in st.session_state:
|
157 |
st.session_state['questions'] = []
|
@@ -163,49 +180,45 @@ if 'current_question' not in st.session_state:
|
|
163 |
st.session_state['current_question'] = 0
|
164 |
if 'total_questions' not in st.session_state:
|
165 |
st.session_state['total_questions'] = 10
|
|
|
|
|
|
|
|
|
166 |
|
167 |
st.title("Mock Interview Bot")
|
168 |
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
if
|
175 |
-
|
176 |
-
|
177 |
-
st.session_state['
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
if
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
st.write("### Interview Report")
|
204 |
-
for i in range(st.session_state['total_questions']):
|
205 |
-
st.write(f"**Question {i+1}:** {st.session_state['questions'][i]}")
|
206 |
-
st.write(f"**Your Answer:** {st.session_state['answers'][i]}")
|
207 |
-
st.write(f"**Feedback:** {st.session_state['feedback'][i]}")
|
208 |
-
st.write("---")
|
209 |
|
210 |
-
if 'current_question' in st.session_state and st.session_state['current_question'] == st.session_state['total_questions']:
|
211 |
-
generate_report()
|
|
|
152 |
|
153 |
return response
|
154 |
|
155 |
+
|
156 |
+
|
157 |
+
|
158 |
+
|
159 |
+
|
160 |
+
|
161 |
+
# ----------------------
|
162 |
+
|
163 |
+
|
164 |
+
def generate_report():
|
165 |
+
st.write("### Interview Report")
|
166 |
+
for i in range(st.session_state['total_questions']):
|
167 |
+
st.write(f"**Question {i+1}:** {st.session_state['questions'][i]}")
|
168 |
+
st.write(f"**Your Answer:** {st.session_state['answers'][i]}")
|
169 |
+
st.write(f"**Feedback:** {st.session_state['feedback'][i]}")
|
170 |
+
st.write("---")
|
171 |
+
|
172 |
# Initialize session state
|
173 |
if 'questions' not in st.session_state:
|
174 |
st.session_state['questions'] = []
|
|
|
180 |
st.session_state['current_question'] = 0
|
181 |
if 'total_questions' not in st.session_state:
|
182 |
st.session_state['total_questions'] = 10
|
183 |
+
if 'question_answered' not in st.session_state:
|
184 |
+
st.session_state['question_answered'] = False
|
185 |
+
if 'interview_started' not in st.session_state:
|
186 |
+
st.session_state['interview_started'] = False
|
187 |
|
188 |
st.title("Mock Interview Bot")
|
189 |
|
190 |
+
if not st.session_state['interview_started']:
|
191 |
+
role = st.selectbox("Select the role:", ["Software Engineer", "Data Scientist", "Product Manager"])
|
192 |
+
topic = st.text_input("Enter the topic:")
|
193 |
+
difficulty_level = st.selectbox("Select difficulty level:", ["Easy", "Medium", "Hard"])
|
194 |
+
|
195 |
+
if st.button("Start Interview"):
|
196 |
+
if role and topic and difficulty_level:
|
197 |
+
st.session_state['questions'] = [generate_question(role, topic, difficulty_level) for _ in range(st.session_state['total_questions'])]
|
198 |
+
st.session_state['current_question'] = 0
|
199 |
+
st.session_state['interview_started'] = True
|
200 |
+
st.session_state['question_answered'] = False
|
201 |
+
|
202 |
+
if st.session_state['interview_started']:
|
203 |
+
current_question = st.session_state['current_question']
|
204 |
+
if current_question < st.session_state['total_questions']:
|
205 |
+
st.write(f"Question {current_question + 1}: {st.session_state['questions'][current_question]}")
|
206 |
+
|
207 |
+
if not st.session_state['question_answered']:
|
208 |
+
answer = st.text_area("Your Answer:", key=f"answer_{current_question}")
|
209 |
+
if st.button("Submit Answer"):
|
210 |
+
if answer:
|
211 |
+
st.session_state['answers'].append(answer)
|
212 |
+
feedback = evaluate_answer(st.session_state['questions'][current_question], answer)
|
213 |
+
st.session_state['feedback'].append(feedback)
|
214 |
+
st.session_state['question_answered'] = True
|
215 |
+
st.write(f"Feedback: {feedback}")
|
216 |
+
|
217 |
+
if st.session_state['question_answered']:
|
218 |
+
if st.button("Next Question"):
|
219 |
+
st.session_state['current_question'] += 1
|
220 |
+
st.session_state['question_answered'] = False
|
221 |
+
else:
|
222 |
+
st.write("Interview Complete! Generating Report...")
|
223 |
+
generate_report()
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
|
|
|
|