joshuarauh commited on
Commit
7ff1e00
·
verified ·
1 Parent(s): dcd5a84

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -17
app.py CHANGED
@@ -924,25 +924,30 @@ j. **Concluding and Intuitive Explanations**
924
  response_text = message.content[0].text
925
  logger.debug("Successfully received response from Anthropic API")
926
 
927
- # Execute SymPy code and append results
928
- if sympy_output is not None:
929
- has_discrepancy = False
930
- SYMPY_CONFIRMED = None
931
- revised_solution = None
932
- final_verification = None
933
-
934
- if "Error" in sympy_output:
935
- verification_text = "SymPy verification failed with error. Manual solution must be verified independently."
936
- SYMPY_CONFIRMED = "Inconclusive"
937
- response_text = f"{response_text}\n\nSymPy Verification Results:\n```\n{sympy_output}\n```\n\nVerification Analysis:\n{verification_text}"
938
- else:
939
- resolution_text, has_discrepancy, revised_solution, SYMPY_CONFIRMED = check_and_resolve_discrepancy(response_text, sympy_output)
940
- response_text = f"{response_text}\n\nSymPy Verification Results:\n```\n{sympy_output}\n```\n\nVerification Analysis:\n{resolution_text}"
941
 
942
- if has_discrepancy and revised_solution:
943
- final_verification = perform_final_verification(revised_solution, SYMPY_CONFIRMED)
944
- response_text += "\n\nFinal Expert Verification:\n" + final_verification
945
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
946
  # add the ChatGPT verification
947
  if include_chatgpt == "yes":
948
  response_text = append_chatgpt_verification(
 
924
  response_text = message.content[0].text
925
  logger.debug("Successfully received response from Anthropic API")
926
 
927
+ # Initialize verification variables
928
+ sympy_output = None
929
+ has_discrepancy = False
930
+ SYMPY_CONFIRMED = None
931
+ revised_solution = None
932
+ final_verification = None
 
 
 
 
 
 
 
 
933
 
934
+ # Execute SymPy code if present
935
+ sympy_output = extract_and_run_sympy_code_simple(response_text)
 
936
 
937
+ # Only proceed with verification if SymPy output exists
938
+ if sympy_output is not None: # Add this check
939
+ if "Error" in sympy_output:
940
+ verification_text = "SymPy verification failed with error. Manual solution must be verified independently."
941
+ SYMPY_CONFIRMED = "Inconclusive"
942
+ response_text = f"{response_text}\n\nSymPy Verification Results:\n```\n{sympy_output}\n```\n\nVerification Analysis:\n{verification_text}"
943
+ else:
944
+ resolution_text, has_discrepancy, revised_solution, SYMPY_CONFIRMED = check_and_resolve_discrepancy(response_text, sympy_output)
945
+ response_text = f"{response_text}\n\nSymPy Verification Results:\n```\n{sympy_output}\n```\n\nVerification Analysis:\n{resolution_text}"
946
+
947
+ if has_discrepancy and revised_solution:
948
+ final_verification = perform_final_verification(revised_solution, SYMPY_CONFIRMED)
949
+ response_text += "\n\nFinal Expert Verification:\n" + final_verification
950
+
951
  # add the ChatGPT verification
952
  if include_chatgpt == "yes":
953
  response_text = append_chatgpt_verification(