Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -586,8 +586,8 @@ STRICT REQUIREMENTS:
|
|
586 |
response_text = f"{response_text}\n\nSymPy Verification Results:\n```\n{sympy_output}\n```\n\nVerification Analysis:\n{resolution_text}"
|
587 |
|
588 |
if has_discrepancy and revised_solution:
|
589 |
-
logger.debug("Performing final verification for
|
590 |
-
final_verification = perform_final_verification(revised_solution)
|
591 |
response_text += "\n\nFinal Expert Verification:\n" + final_verification
|
592 |
|
593 |
# Create LaTeX content
|
@@ -686,6 +686,7 @@ def check_and_resolve_discrepancy(initial_response, sympy_output):
|
|
686 |
to end, including all parts that were correct and the corrections for any incorrect parts.
|
687 |
Do not refer to the original solution or say things like "the rest remains the same" - write
|
688 |
out everything in full.
|
|
|
689 |
|
690 |
Original solution:
|
691 |
{initial_response}
|
@@ -766,17 +767,24 @@ Please maintain the same LaTeX formatting as the original solution."""
|
|
766 |
revised_solution = parts[1].strip()
|
767 |
except Exception as e:
|
768 |
logger.error(f"Error in solution recheck: {str(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
769 |
|
770 |
-
return resolution_text, has_discrepancy, revised_solution
|
771 |
|
772 |
except Exception as e:
|
773 |
logger.error(f"Error in discrepancy resolution: {str(e)}")
|
774 |
resolution_text = f"Error in resolution: {str(e)}"
|
775 |
has_discrepancy = False # Explicitly set in error case
|
776 |
revised_solution = None
|
777 |
-
return resolution_text, has_discrepancy, revised_solution
|
778 |
|
779 |
-
def perform_final_verification(revised_solution):
|
780 |
"""
|
781 |
Perform a final verification of the revised solution.
|
782 |
"""
|
@@ -804,6 +812,8 @@ Please follow these steps exactly:
|
|
804 |
- Any missing steps or assumptions
|
805 |
- Any necessary additional proofs or derivations
|
806 |
|
|
|
|
|
807 |
Your complete solution must:
|
808 |
- Be completely self-contained
|
809 |
- Not refer to the original solution
|
@@ -813,8 +823,7 @@ Your complete solution must:
|
|
813 |
- When referring to the dollar as a currency, never use the `$` symbol but rather write out the word dollar
|
814 |
|
815 |
Remember to write out the complete solution even if you only need to add a few steps - the goal is to have a single, complete, verified solution that includes everything necessary for full mathematical rigor.
|
816 |
-
|
817 |
-
At the end if you have a different solution than the Revised Solution you verified, explain exactly why."""
|
818 |
|
819 |
try:
|
820 |
# Make API call for final verification
|
|
|
586 |
response_text = f"{response_text}\n\nSymPy Verification Results:\n```\n{sympy_output}\n```\n\nVerification Analysis:\n{resolution_text}"
|
587 |
|
588 |
if has_discrepancy and revised_solution:
|
589 |
+
logger.debug("Performing final verification for problem with discrepancy")
|
590 |
+
final_verification = perform_final_verification(revised_solution,sympy_correct)
|
591 |
response_text += "\n\nFinal Expert Verification:\n" + final_verification
|
592 |
|
593 |
# Create LaTeX content
|
|
|
686 |
to end, including all parts that were correct and the corrections for any incorrect parts.
|
687 |
Do not refer to the original solution or say things like "the rest remains the same" - write
|
688 |
out everything in full.
|
689 |
+
4. Start with "SYMPY_CORRECT: True" or "SYMPY_CORRECT: False" on its own line.
|
690 |
|
691 |
Original solution:
|
692 |
{initial_response}
|
|
|
767 |
revised_solution = parts[1].strip()
|
768 |
except Exception as e:
|
769 |
logger.error(f"Error in solution recheck: {str(e)}")
|
770 |
+
|
771 |
+
# Parse whether SymPy was correct
|
772 |
+
sympy_correct = None
|
773 |
+
if "SYMPY_CORRECT: True" in resolution_text:
|
774 |
+
sympy_correct = True
|
775 |
+
elif "SYMPY_CORRECT: False" in resolution_text:
|
776 |
+
sympy_correct = False
|
777 |
|
778 |
+
return resolution_text, has_discrepancy, revised_solution, sympy_correct
|
779 |
|
780 |
except Exception as e:
|
781 |
logger.error(f"Error in discrepancy resolution: {str(e)}")
|
782 |
resolution_text = f"Error in resolution: {str(e)}"
|
783 |
has_discrepancy = False # Explicitly set in error case
|
784 |
revised_solution = None
|
785 |
+
return resolution_text, has_discrepancy, revised_solution, sympy_correct
|
786 |
|
787 |
+
def perform_final_verification(revised_solution, sympy_correct):
|
788 |
"""
|
789 |
Perform a final verification of the revised solution.
|
790 |
"""
|
|
|
812 |
- Any missing steps or assumptions
|
813 |
- Any necessary additional proofs or derivations
|
814 |
|
815 |
+
4. The answer aligns with the {'SymPy' if sympy_correct else 'original'} approach proven correct
|
816 |
+
|
817 |
Your complete solution must:
|
818 |
- Be completely self-contained
|
819 |
- Not refer to the original solution
|
|
|
823 |
- When referring to the dollar as a currency, never use the `$` symbol but rather write out the word dollar
|
824 |
|
825 |
Remember to write out the complete solution even if you only need to add a few steps - the goal is to have a single, complete, verified solution that includes everything necessary for full mathematical rigor.
|
826 |
+
"""
|
|
|
827 |
|
828 |
try:
|
829 |
# Make API call for final verification
|