Spaces:
Sleeping
Sleeping
namberino
commited on
Commit
·
fcb583a
1
Parent(s):
d82acc6
Update generate from pdf functionality
Browse files- app.py +1 -1
- generator.py +8 -1
app.py
CHANGED
|
@@ -282,7 +282,7 @@ async def generate_endpoint(
|
|
| 282 |
counter += 1
|
| 283 |
|
| 284 |
except Exception as e:
|
| 285 |
-
raise HTTPException(status_code=500, detail=f"Generation from
|
| 286 |
|
| 287 |
validation_report = None
|
| 288 |
|
|
|
|
| 282 |
counter += 1
|
| 283 |
|
| 284 |
except Exception as e:
|
| 285 |
+
raise HTTPException(status_code=500, detail=f"Generation from file failed: {e}")
|
| 286 |
|
| 287 |
validation_report = None
|
| 288 |
|
generator.py
CHANGED
|
@@ -279,6 +279,7 @@ class RAGMCQ:
|
|
| 279 |
if isinstance(options, list):
|
| 280 |
options = {str(i+1): o for i, o in enumerate(options)}
|
| 281 |
correct_key = payload.get("đáp án") or payload.get("answer") or payload.get("correct") or None
|
|
|
|
| 282 |
correct_text = ""
|
| 283 |
if isinstance(correct_key, str) and correct_key.strip() in options:
|
| 284 |
correct_text = options[correct_key.strip()]
|
|
@@ -290,6 +291,12 @@ class RAGMCQ:
|
|
| 290 |
)
|
| 291 |
payload["difficulty"] = {"score": diff_score, "label": diff_label}
|
| 292 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
qcount += 1
|
| 294 |
output[str(qcount)] = mcq_block[item]
|
| 295 |
if qcount >= n_questions:
|
|
@@ -969,7 +976,7 @@ class RAGMCQ:
|
|
| 969 |
|
| 970 |
#? change estimate
|
| 971 |
diff_score, diff_label, components = self._estimate_difficulty_for_generation( # type: ignore
|
| 972 |
-
q_text=q_text, options={k: str(v) for k,v in options.items()}, correct_text=str(correct_text), context_text=structured_context, concepts_used
|
| 973 |
)
|
| 974 |
|
| 975 |
payload["độ khó"] = {"điểm": diff_score, "mức độ": diff_label}
|
|
|
|
| 279 |
if isinstance(options, list):
|
| 280 |
options = {str(i+1): o for i, o in enumerate(options)}
|
| 281 |
correct_key = payload.get("đáp án") or payload.get("answer") or payload.get("correct") or None
|
| 282 |
+
concepts = payload.get("khái niệm sử dụng") or payload.get("concepts") or payload.get("concepts used") or None
|
| 283 |
correct_text = ""
|
| 284 |
if isinstance(correct_key, str) and correct_key.strip() in options:
|
| 285 |
correct_text = options[correct_key.strip()]
|
|
|
|
| 291 |
)
|
| 292 |
payload["difficulty"] = {"score": diff_score, "label": diff_label}
|
| 293 |
|
| 294 |
+
diff_score, diff_label, components = self._estimate_difficulty_for_generation( # type: ignore
|
| 295 |
+
q_text=q_text, options={k: str(v) for k,v in options.items()}, correct_text=str(correct_text), context_text=structured_context, concepts_used=concepts
|
| 296 |
+
)
|
| 297 |
+
|
| 298 |
+
payload["độ khó"] = {"điểm": diff_score, "mức độ": diff_label}
|
| 299 |
+
|
| 300 |
qcount += 1
|
| 301 |
output[str(qcount)] = mcq_block[item]
|
| 302 |
if qcount >= n_questions:
|
|
|
|
| 976 |
|
| 977 |
#? change estimate
|
| 978 |
diff_score, diff_label, components = self._estimate_difficulty_for_generation( # type: ignore
|
| 979 |
+
q_text=q_text, options={k: str(v) for k,v in options.items()}, correct_text=str(correct_text), context_text=structured_context, concepts_used=concepts
|
| 980 |
)
|
| 981 |
|
| 982 |
payload["độ khó"] = {"điểm": diff_score, "mức độ": diff_label}
|