Mohinikathro commited on
Commit
f5d0565
·
verified ·
1 Parent(s): a533e1d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -247,18 +247,25 @@ def end_interview(state):
247
  return convert_for_gradio(state["conversation"]), state
248
 
249
  def prepare_downloadable_summary(state):
 
 
 
 
 
250
  summary = {
251
  "name": state["name"],
252
  "domain": state["domain"],
253
  "level": state["level"],
254
  "company": state["company"],
255
- "score": f"{sum(rating_scores.get(ev['rating'], 0) for ev in state['evaluations'])}/{len(state['evaluations']) * 3}",
 
 
256
  "evaluations": state["evaluations"]
257
  }
258
 
259
  with tempfile.NamedTemporaryFile(mode="w+", delete=False, suffix=".json") as f:
260
  json.dump(summary, f, indent=4)
261
- return f.name # Return the path to the downloadable file
262
 
263
  def clear_state():
264
  return [], reset_state("", "", "", "Entry-Level")
 
247
  return convert_for_gradio(state["conversation"]), state
248
 
249
  def prepare_downloadable_summary(state):
250
+ total_score = sum(rating_scores.get(ev["rating"], 0) for ev in state["evaluations"])
251
+ max_score = len(state["evaluations"]) * 3
252
+ percentage = (total_score / max_score * 100) if max_score > 0 else 0
253
+ category = next(label for threshold, label in score_categories if percentage >= threshold)
254
+
255
  summary = {
256
  "name": state["name"],
257
  "domain": state["domain"],
258
  "level": state["level"],
259
  "company": state["company"],
260
+ "score": f"{total_score}/{max_score}",
261
+ "percentage": round(percentage, 2),
262
+ "category": category,
263
  "evaluations": state["evaluations"]
264
  }
265
 
266
  with tempfile.NamedTemporaryFile(mode="w+", delete=False, suffix=".json") as f:
267
  json.dump(summary, f, indent=4)
268
+ return f.name
269
 
270
  def clear_state():
271
  return [], reset_state("", "", "", "Entry-Level")