joshuarauh commited on
Commit
f08c424
·
verified ·
1 Parent(s): 3b9c255

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -13
app.py CHANGED
@@ -678,18 +678,19 @@ def append_chatgpt_verification(initial_response, sympy_correct, final_verificat
678
  # Get ChatGPT's verification
679
  chatgpt_verification = verify_with_chatgpt(question, solution_text)
680
 
681
- # Append verification to the response
682
- full_response = f"{initial_response}\n\nChatGPT Verification and Grading:\n{chatgpt_verification}"
 
 
683
 
684
- return full_response
685
-
686
  except Exception as e:
687
  logger.error(f"Error in verification process: {str(e)}")
688
  return initial_response + f"\n\nError in ChatGPT verification: {str(e)}"
689
 
690
- def generate_question(subject, difficulty, question_type, use_enhancement=False):
691
  """Generate a single math question with additional verification"""
692
  try:
 
693
  if not os.environ.get('ANTHROPIC_API_KEY'):
694
  logger.error("Anthropic API key not found")
695
  return "Error: Anthropic API key not configured", None, None
@@ -858,11 +859,12 @@ j. **Concluding and Intuitive Explanations**
858
 
859
  # Execute SymPy code and append results
860
  sympy_output = extract_and_run_sympy_code_simple(response_text)
 
 
 
 
861
 
862
  if sympy_output:
863
- has_discrepancy = False # Initialize here
864
- sympy_correct = None
865
- revised_solution = None
866
  if "Error" not in sympy_output:
867
  resolution_text, has_discrepancy, revised_solution, sympy_correct = check_and_resolve_discrepancy(response_text, sympy_output)
868
  response_text = f"{response_text}\n\nSymPy Verification Results:\n```\n{sympy_output}\n```\n\nVerification Analysis:\n{resolution_text}"
@@ -1191,11 +1193,12 @@ with gr.Blocks() as interface:
1191
 
1192
  # Add ChatGPT verification toggle
1193
  chatgpt_verify = gr.Radio(
1194
- choices=["yes", "no"],
1195
- label="Include ChatGPT Verification",
1196
- info="Enable/disable ChatGPT grading (saves credits)",
1197
- value="no" # Default to off to save credits
1198
- )
 
1199
 
1200
  generate_btn = gr.Button("Generate Question")
1201
 
 
678
  # Get ChatGPT's verification
679
  chatgpt_verification = verify_with_chatgpt(question, solution_text)
680
 
681
+ if chatgpt_verification: # Add this check
682
+ full_response = f"{initial_response}\n\nChatGPT Verification and Grading:\n{chatgpt_verification}"
683
+ return full_response
684
+ return initial_response
685
 
 
 
686
  except Exception as e:
687
  logger.error(f"Error in verification process: {str(e)}")
688
  return initial_response + f"\n\nError in ChatGPT verification: {str(e)}"
689
 
690
+ def generate_question(subject, difficulty, question_type, use_enhancement=False, include_chatgpt="no"):
691
  """Generate a single math question with additional verification"""
692
  try:
693
+ logger.debug(f"ChatGPT verification: {'enabled' if include_chatgpt == 'yes' else 'disabled'}")
694
  if not os.environ.get('ANTHROPIC_API_KEY'):
695
  logger.error("Anthropic API key not found")
696
  return "Error: Anthropic API key not configured", None, None
 
859
 
860
  # Execute SymPy code and append results
861
  sympy_output = extract_and_run_sympy_code_simple(response_text)
862
+ has_discrepancy = False # Initialize outside the if block
863
+ sympy_correct = None
864
+ revised_solution = None
865
+ final_verification = None
866
 
867
  if sympy_output:
 
 
 
868
  if "Error" not in sympy_output:
869
  resolution_text, has_discrepancy, revised_solution, sympy_correct = check_and_resolve_discrepancy(response_text, sympy_output)
870
  response_text = f"{response_text}\n\nSymPy Verification Results:\n```\n{sympy_output}\n```\n\nVerification Analysis:\n{resolution_text}"
 
1193
 
1194
  # Add ChatGPT verification toggle
1195
  chatgpt_verify = gr.Radio(
1196
+ choices=["yes", "no"],
1197
+ label="Include ChatGPT Verification",
1198
+ info="Enable/disable ChatGPT grading (saves credits)",
1199
+ value="no" # Default to off to save credits
1200
+ )
1201
+
1202
 
1203
  generate_btn = gr.Button("Generate Question")
1204