burtenshaw commited on
Commit
136f08a
·
1 Parent(s): 3a3fcba

improve logging

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -94,7 +94,7 @@ def check_code(
94
  is_correct = response.upper().startswith("CORRECT")
95
 
96
  # Add the explanation to the status text with emoji
97
- explanation = response.split("\n", 1)[1] if "\n" in response else ""
98
  status = "✅ Correct!" if is_correct else "❌ Incorrect!" + f"\n\n{explanation}"
99
  gr.Info(f"{status}\n\n{explanation}")
100
 
@@ -103,8 +103,9 @@ def check_code(
103
  except Exception as e:
104
  gr.Warning(f"Error checking code: {str(e)}")
105
  # Fall back to simple string comparison if LLM fails
106
- is_correct = formatted_user_code.strip() == formatted_solution.strip()
107
- status = "✅ Correct!" if is_correct else "❌ Incorrect!" + f"\n\n{explanation}"
 
108
  gr.Info(f"{status} (Fallback comparison)")
109
  return is_correct
110
 
 
94
  is_correct = response.upper().startswith("CORRECT")
95
 
96
  # Add the explanation to the status text with emoji
97
+ explanation = response.lower().split("correct")[1]
98
  status = "✅ Correct!" if is_correct else "❌ Incorrect!" + f"\n\n{explanation}"
99
  gr.Info(f"{status}\n\n{explanation}")
100
 
 
103
  except Exception as e:
104
  gr.Warning(f"Error checking code: {str(e)}")
105
  # Fall back to simple string comparison if LLM fails
106
+ status = (
107
+ "✅ Correct!" if is_correct else "❌ Incorrect!" + f"\n\nError: {str(e)}"
108
+ )
109
  gr.Info(f"{status} (Fallback comparison)")
110
  return is_correct
111