Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -90,12 +90,13 @@ def generate_question(prompt, domain, state=None):
|
|
90 |
if state is not None:
|
91 |
if (question not in state["asked_questions"] and
|
92 |
(subtopic is None or subtopic not in state["asked_subtopics"])):
|
93 |
-
state["asked_questions"].
|
94 |
if subtopic:
|
95 |
-
state["asked_subtopics"].
|
96 |
return question
|
97 |
return question
|
98 |
|
|
|
99 |
def evaluate_response(response, question):
|
100 |
eval_prompt = (
|
101 |
"Evaluate the following candidate response to an interview question.\n\n"
|
@@ -130,8 +131,8 @@ def reset_state(name, domain, company, level):
|
|
130 |
"domain": domain,
|
131 |
"company": company,
|
132 |
"level": level,
|
133 |
-
"asked_questions":
|
134 |
-
"asked_subtopics":
|
135 |
"conversation": [],
|
136 |
"evaluations": [],
|
137 |
"interview_active": True
|
@@ -204,8 +205,8 @@ def clear_state():
|
|
204 |
"domain": "",
|
205 |
"company": "",
|
206 |
"level": "",
|
207 |
-
"asked_questions":
|
208 |
-
"asked_subtopics":
|
209 |
"conversation": [],
|
210 |
"evaluations": [],
|
211 |
"interview_active": False
|
@@ -236,7 +237,8 @@ with gr.Blocks() as demo:
|
|
236 |
exit_button = gr.Button("Exit Interview")
|
237 |
clear_button = gr.Button("Clear Session")
|
238 |
|
239 |
-
state
|
|
|
240 |
|
241 |
start_button.click(start_interview,
|
242 |
inputs=[name_input, domain_input, company_input, level_input],
|
@@ -245,4 +247,4 @@ with gr.Blocks() as demo:
|
|
245 |
exit_button.click(end_interview, inputs=state, outputs=[chatbot, state])
|
246 |
clear_button.click(clear_state, outputs=[chatbot, state])
|
247 |
|
248 |
-
demo.launch(
|
|
|
90 |
if state is not None:
|
91 |
if (question not in state["asked_questions"] and
|
92 |
(subtopic is None or subtopic not in state["asked_subtopics"])):
|
93 |
+
state["asked_questions"].append(question)
|
94 |
if subtopic:
|
95 |
+
state["asked_subtopics"].append(subtopic)
|
96 |
return question
|
97 |
return question
|
98 |
|
99 |
+
|
100 |
def evaluate_response(response, question):
|
101 |
eval_prompt = (
|
102 |
"Evaluate the following candidate response to an interview question.\n\n"
|
|
|
131 |
"domain": domain,
|
132 |
"company": company,
|
133 |
"level": level,
|
134 |
+
"asked_questions": [],
|
135 |
+
"asked_subtopics": [],
|
136 |
"conversation": [],
|
137 |
"evaluations": [],
|
138 |
"interview_active": True
|
|
|
205 |
"domain": "",
|
206 |
"company": "",
|
207 |
"level": "",
|
208 |
+
"asked_questions": [],
|
209 |
+
"asked_subtopics": [],
|
210 |
"conversation": [],
|
211 |
"evaluations": [],
|
212 |
"interview_active": False
|
|
|
237 |
exit_button = gr.Button("Exit Interview")
|
238 |
clear_button = gr.Button("Clear Session")
|
239 |
|
240 |
+
# Initialize state with proper structure
|
241 |
+
state = gr.State(value=reset_state("", "", "", "Entry-Level"))
|
242 |
|
243 |
start_button.click(start_interview,
|
244 |
inputs=[name_input, domain_input, company_input, level_input],
|
|
|
247 |
exit_button.click(end_interview, inputs=state, outputs=[chatbot, state])
|
248 |
clear_button.click(clear_state, outputs=[chatbot, state])
|
249 |
|
250 |
+
demo.launch()
|