Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -90,21 +90,26 @@ def generate_question(prompt, domain, state=None, max_attempts=10):
|
|
90 |
|
91 |
raise RuntimeError("Failed to generate a unique question after multiple attempts.")
|
92 |
|
93 |
-
def reset_state(domain, company):
|
94 |
return {
|
95 |
"domain": domain,
|
96 |
"company": company,
|
|
|
|
|
97 |
"asked_questions": set(),
|
98 |
"asked_subtopics": set(),
|
99 |
-
"conversation": []
|
100 |
}
|
101 |
|
102 |
-
def start_interview(domain, company):
|
103 |
-
state = reset_state(domain, company)
|
104 |
-
prompt =
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
108 |
|
109 |
def submit_response(candidate_response, state):
|
110 |
state["conversation"].append({"role": "user", "content": candidate_response})
|
@@ -120,6 +125,8 @@ with gr.Blocks() as demo:
|
|
120 |
with gr.Row():
|
121 |
domain_input = gr.Textbox(label="Domain")
|
122 |
company_input = gr.Textbox(label="Company (Optional)")
|
|
|
|
|
123 |
|
124 |
start_button = gr.Button("π Start Interview")
|
125 |
chatbot = gr.Chatbot(label="Interview Conversation", type="messages")
|
@@ -131,7 +138,11 @@ with gr.Blocks() as demo:
|
|
131 |
state = gr.State({}) # Session state holder
|
132 |
|
133 |
# Hook buttons to logic
|
134 |
-
start_button.click(
|
|
|
|
|
|
|
|
|
135 |
submit_button.click(submit_response, inputs=[response_input, state], outputs=[chatbot, state]).then(
|
136 |
lambda: "", inputs=[], outputs=[response_input] # Clear textbox after submit
|
137 |
)
|
|
|
90 |
|
91 |
raise RuntimeError("Failed to generate a unique question after multiple attempts.")
|
92 |
|
93 |
+
def reset_state(domain, company, role, year):
|
94 |
return {
|
95 |
"domain": domain,
|
96 |
"company": company,
|
97 |
+
"role": role,
|
98 |
+
"year": year,
|
99 |
"asked_questions": set(),
|
100 |
"asked_subtopics": set(),
|
101 |
+
"conversation": []
|
102 |
}
|
103 |
|
104 |
+
def start_interview(domain, company, role, year):
|
105 |
+
state = reset_state(domain, company, role, year)
|
106 |
+
prompt = (
|
107 |
+
f"Domain: {domain}. "
|
108 |
+
f"Company: {company or 'N/A'}. "
|
109 |
+
f"Role: {role or 'N/A'}. "
|
110 |
+
f"Year: {year or 'N/A'}. "
|
111 |
+
"Generate the first question:"
|
112 |
+
)
|
113 |
|
114 |
def submit_response(candidate_response, state):
|
115 |
state["conversation"].append({"role": "user", "content": candidate_response})
|
|
|
125 |
with gr.Row():
|
126 |
domain_input = gr.Textbox(label="Domain")
|
127 |
company_input = gr.Textbox(label="Company (Optional)")
|
128 |
+
role_input = gr.Textbox(label="Role (e.g., Data Analyst, MLE)", placeholder="Enter your target role")
|
129 |
+
year_input = gr.Textbox(label="Year (Optional)", placeholder="e.g., 2024")
|
130 |
|
131 |
start_button = gr.Button("π Start Interview")
|
132 |
chatbot = gr.Chatbot(label="Interview Conversation", type="messages")
|
|
|
138 |
state = gr.State({}) # Session state holder
|
139 |
|
140 |
# Hook buttons to logic
|
141 |
+
start_button.click(
|
142 |
+
start_interview,
|
143 |
+
inputs=[domain_input, company_input, role_input, year_input],
|
144 |
+
outputs=[chatbot, state]
|
145 |
+
)
|
146 |
submit_button.click(submit_response, inputs=[response_input, state], outputs=[chatbot, state]).then(
|
147 |
lambda: "", inputs=[], outputs=[response_input] # Clear textbox after submit
|
148 |
)
|