Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -530,7 +530,7 @@ STRICT REQUIREMENTS:
|
|
| 530 |
logger.debug("Successfully created temporary files")
|
| 531 |
|
| 532 |
return response_text, questions_path, full_path
|
| 533 |
-
|
| 534 |
except Exception as e:
|
| 535 |
logger.error(f"Error generating question: {str(e)}")
|
| 536 |
return f"Error: {str(e)}", None, None
|
|
@@ -605,7 +605,7 @@ def check_and_resolve_discrepancy(initial_response, sympy_output):
|
|
| 605 |
If the two answers are inconsistent with each other then please:
|
| 606 |
1. Identify which solution is correct
|
| 607 |
2. Explain the error in the incorrect solution
|
| 608 |
-
3. Provide a revised complete solution
|
| 609 |
|
| 610 |
Original solution:
|
| 611 |
{initial_response}
|
|
@@ -634,31 +634,26 @@ Please maintain the same LaTeX formatting as the original solution."""
|
|
| 634 |
resolution_text += "\n\nNew SymPy Verification Results:\n```\n" + new_sympy_output + "\n```"
|
| 635 |
|
| 636 |
# Determine if there was a discrepancy that required a revised solution
|
| 637 |
-
#
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
for phrase in revision_phrases:
|
| 643 |
-
if phrase in resolution_text.lower():
|
| 644 |
-
has_discrepancy = True
|
| 645 |
-
found_phrase = phrase
|
| 646 |
-
break
|
| 647 |
-
|
| 648 |
-
# Extract revised solution if it exists
|
| 649 |
revised_solution = None
|
| 650 |
-
if has_discrepancy
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
if len(
|
| 654 |
-
revised_solution =
|
| 655 |
|
| 656 |
-
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
|
|
|
|
|
|
|
|
|
|
| 662 |
|
| 663 |
return resolution_text, has_discrepancy, revised_solution
|
| 664 |
|
|
@@ -684,7 +679,7 @@ Please:
|
|
| 684 |
|
| 685 |
If you find any issues:
|
| 686 |
1. Clearly explain what is incorrect or missing
|
| 687 |
-
2. Provide a
|
| 688 |
3. Maintain the same LaTeX formatting as the original
|
| 689 |
4. Include any missing assumptions or conditions
|
| 690 |
5. If relevant, provide corrected SymPy code
|
|
@@ -717,6 +712,7 @@ Please ensure any corrected solution maintains proper LaTeX formatting with $ fo
|
|
| 717 |
except Exception as e:
|
| 718 |
logger.error(f"Error in final verification: {str(e)}")
|
| 719 |
return f"Error in final verification: {str(e)}"
|
|
|
|
| 720 |
|
| 721 |
# Create Gradio interface
|
| 722 |
with gr.Blocks() as interface:
|
|
|
|
| 530 |
logger.debug("Successfully created temporary files")
|
| 531 |
|
| 532 |
return response_text, questions_path, full_path
|
| 533 |
+
|
| 534 |
except Exception as e:
|
| 535 |
logger.error(f"Error generating question: {str(e)}")
|
| 536 |
return f"Error: {str(e)}", None, None
|
|
|
|
| 605 |
If the two answers are inconsistent with each other then please:
|
| 606 |
1. Identify which solution is correct
|
| 607 |
2. Explain the error in the incorrect solution
|
| 608 |
+
3. Provide a revised complete solution that fixes any errors and does not refer to SymPy
|
| 609 |
|
| 610 |
Original solution:
|
| 611 |
{initial_response}
|
|
|
|
| 634 |
resolution_text += "\n\nNew SymPy Verification Results:\n```\n" + new_sympy_output + "\n```"
|
| 635 |
|
| 636 |
# Determine if there was a discrepancy that required a revised solution
|
| 637 |
+
# First check if there's an inconsistency mentioned
|
| 638 |
+
has_discrepancy = "inconsistent" in resolution_text.lower() or "inconsistency" in resolution_text.lower()
|
| 639 |
+
|
| 640 |
+
# Look for the exact phrase we required in the prompt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 641 |
revised_solution = None
|
| 642 |
+
if has_discrepancy:
|
| 643 |
+
marker = "Here is the revised complete solution:"
|
| 644 |
+
parts = resolution_text.split(marker, maxsplit=1)
|
| 645 |
+
if len(parts) > 1:
|
| 646 |
+
revised_solution = parts[1].strip()
|
| 647 |
|
| 648 |
+
if not revised_solution:
|
| 649 |
+
# Fallback check for common revision phrases
|
| 650 |
+
revision_phrases = ["revised complete solution:", "revised solution:", "correct solution:", "corrected solution:"]
|
| 651 |
+
for phrase in revision_phrases:
|
| 652 |
+
if phrase in resolution_text.lower():
|
| 653 |
+
parts = resolution_text.split(phrase, maxsplit=1)
|
| 654 |
+
if len(parts) > 1:
|
| 655 |
+
revised_solution = parts[1].strip()
|
| 656 |
+
break
|
| 657 |
|
| 658 |
return resolution_text, has_discrepancy, revised_solution
|
| 659 |
|
|
|
|
| 679 |
|
| 680 |
If you find any issues:
|
| 681 |
1. Clearly explain what is incorrect or missing
|
| 682 |
+
2. Provide a complete corrected solution
|
| 683 |
3. Maintain the same LaTeX formatting as the original
|
| 684 |
4. Include any missing assumptions or conditions
|
| 685 |
5. If relevant, provide corrected SymPy code
|
|
|
|
| 712 |
except Exception as e:
|
| 713 |
logger.error(f"Error in final verification: {str(e)}")
|
| 714 |
return f"Error in final verification: {str(e)}"
|
| 715 |
+
|
| 716 |
|
| 717 |
# Create Gradio interface
|
| 718 |
with gr.Blocks() as interface:
|