Mehdi commited on
Commit ·
2f3700c
1
Parent(s): 80f7ff0
debug: add prints in new_question to trace call and LLM progress
Browse files
app.py
CHANGED
|
@@ -269,14 +269,19 @@ def load_pdf(pdf_file, language):
|
|
| 269 |
|
| 270 |
@spaces.GPU(duration=180)
|
| 271 |
def new_question(chunks, language):
|
|
|
|
| 272 |
s = UI[language]
|
| 273 |
if not chunks:
|
|
|
|
| 274 |
return s["no_pdf"], "", s["no_pdf"]
|
| 275 |
try:
|
| 276 |
chunk = random.choice(chunks)
|
|
|
|
| 277 |
question = generate_question(chunk, language=language)
|
|
|
|
| 278 |
return question, chunk, ""
|
| 279 |
except Exception as e:
|
|
|
|
| 280 |
err = f"Erreur : {e}"
|
| 281 |
return err, "", err
|
| 282 |
|
|
|
|
| 269 |
|
| 270 |
@spaces.GPU(duration=180)
|
| 271 |
def new_question(chunks, language):
|
| 272 |
+
print(f"[new_question] called — {len(chunks)} chunks, lang={language}")
|
| 273 |
s = UI[language]
|
| 274 |
if not chunks:
|
| 275 |
+
print("[new_question] no chunks, returning early")
|
| 276 |
return s["no_pdf"], "", s["no_pdf"]
|
| 277 |
try:
|
| 278 |
chunk = random.choice(chunks)
|
| 279 |
+
print(f"[new_question] chunk selected ({len(chunk)} chars), calling LLM…")
|
| 280 |
question = generate_question(chunk, language=language)
|
| 281 |
+
print(f"[new_question] question generated: {question[:80]!r}")
|
| 282 |
return question, chunk, ""
|
| 283 |
except Exception as e:
|
| 284 |
+
import traceback; traceback.print_exc()
|
| 285 |
err = f"Erreur : {e}"
|
| 286 |
return err, "", err
|
| 287 |
|