Mohinikathro commited on
Commit
ddee870
·
verified ·
1 Parent(s): 5c8c4b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -5
app.py CHANGED
@@ -182,11 +182,56 @@ def reset_state(name, domain, company, level):
182
  }
183
 
184
  def start_interview(name, domain, company, level):
185
- state = reset_state(name, domain, company, level)
186
- prompt = f"Domain: {domain}. Candidate experience level: {level}. Generate the first question:"
187
- question = generate_question(prompt, domain, state)
188
- state["conversation"].append({"role": "Interviewer", "content": question})
189
- return state["conversation"], state
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
 
191
  def submit_response(response, state):
192
  if not state["interview_active"]:
 
182
  }
183
 
184
  def start_interview(name, domain, company, level):
185
+ try:
186
+ # Print all input parameters
187
+ print(f"Start Interview Called:")
188
+ print(f"Name: {name}")
189
+ print(f"Domain: {domain}")
190
+ print(f"Company: {company}")
191
+ print(f"Level: {level}")
192
+
193
+ # Validate inputs
194
+ if not name or not domain:
195
+ return [{"role": "System", "content": "Please provide a name and domain"}], None
196
+
197
+ # Create initial state
198
+ state = reset_state(name, domain, company, level)
199
+ print("State reset successfully")
200
+
201
+ # Prepare prompt for question generation
202
+ prompt = f"Domain: {domain}. Candidate experience level: {level}. Generate the first question:"
203
+ print(f"Prompt for question generation: {prompt}")
204
+
205
+ # Verify model is ready
206
+ print("Model device:", model.device)
207
+ print("Model ready:", model is not None)
208
+
209
+ # Generate first question
210
+ try:
211
+ question = generate_question(prompt, domain, state)
212
+ print(f"Generated Question: {question}")
213
+ except Exception as q_error:
214
+ print(f"Question Generation Error: {q_error}")
215
+ question = f"Error generating question: {q_error}"
216
+
217
+ # Append question to conversation
218
+ state["conversation"].append({"role": "Interviewer", "content": question})
219
+
220
+ return state["conversation"], state
221
+
222
+ except Exception as e:
223
+ print(f"CRITICAL ERROR in start_interview: {e}")
224
+ import traceback
225
+ traceback.print_exc()
226
+ return [{"role": "System", "content": f"Critical error: {e}"}], None
227
+
228
+ # Modify Gradio launch to print any errors
229
+ try:
230
+ demo.launch(debug=True)
231
+ except Exception as e:
232
+ print(f"Gradio Launch Error: {e}")
233
+ import traceback
234
+ traceback.print_exc()
235
 
236
  def submit_response(response, state):
237
  if not state["interview_active"]: