Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -540,35 +540,30 @@ def get_solution_for_verification(response_text, sympy_correct, final_verificati
|
|
540 |
# If we can't even split paragraphs, just return the whole text as both question and solution
|
541 |
return response_text.strip(), response_text.strip()
|
542 |
|
543 |
-
# Extract question
|
544 |
question = response_text[q_start:q_end].strip()
|
545 |
-
original_solution = response_text[q_end:]
|
546 |
-
|
547 |
-
# If no sympy verification was done, treat as correct and use original
|
548 |
-
if sympy_correct is None:
|
549 |
-
sympy_correct = True
|
550 |
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
if
|
555 |
-
solution =
|
|
|
|
|
556 |
else:
|
557 |
-
solution
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
558 |
else:
|
559 |
-
|
560 |
-
if final_verification:
|
561 |
-
# Extract the solution after the marker
|
562 |
-
marker = "Here is the complete verified solution:"
|
563 |
-
if marker in final_verification:
|
564 |
-
solution = final_verification.split(marker)[1].strip()
|
565 |
-
else:
|
566 |
-
# Fallback to using the whole verification text
|
567 |
-
solution = final_verification.strip()
|
568 |
-
else:
|
569 |
-
# Fallback to original if no final verification
|
570 |
-
solution = original_solution.strip()
|
571 |
|
|
|
572 |
return question, solution
|
573 |
|
574 |
def verify_with_chatgpt(question, solution):
|
|
|
540 |
# If we can't even split paragraphs, just return the whole text as both question and solution
|
541 |
return response_text.strip(), response_text.strip()
|
542 |
|
543 |
+
# Extract question
|
544 |
question = response_text[q_start:q_end].strip()
|
|
|
|
|
|
|
|
|
|
|
545 |
|
546 |
+
# If we have a final verification solution, use that
|
547 |
+
if final_verification:
|
548 |
+
marker = "Here is the complete verified solution:"
|
549 |
+
if marker in final_verification:
|
550 |
+
solution = final_verification.split(marker)[1].strip()
|
551 |
+
logger.debug("Using final verified solution for verification")
|
552 |
+
return question, solution
|
553 |
else:
|
554 |
+
# If marker not found in final verification, extract solution part
|
555 |
+
logger.debug("Marker not found in final verification, using full verification text")
|
556 |
+
return question, final_verification.strip()
|
557 |
+
|
558 |
+
# Otherwise, extract original solution (before SymPy code if present)
|
559 |
+
original_solution = response_text[q_end:]
|
560 |
+
sympy_start = original_solution.find('```python')
|
561 |
+
if sympy_start != -1:
|
562 |
+
solution = original_solution[:sympy_start].strip()
|
563 |
else:
|
564 |
+
solution = original_solution.strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
565 |
|
566 |
+
logger.debug("Using original solution for verification")
|
567 |
return question, solution
|
568 |
|
569 |
def verify_with_chatgpt(question, solution):
|