Tonic commited on
Commit
5289607
Β·
verified Β·
1 Parent(s): aedf8bf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -33,11 +33,10 @@ def extract_code(response):
33
  if not matches:
34
  return "None"
35
 
36
- # Get the last match which should contain the complete code including model output
37
  full_content = matches[-1].strip()
38
 
39
  # Clean up any duplicate headers or content
40
- # Split the content into lines
41
  lines = full_content.split('\n')
42
  cleaned_lines = []
43
  seen_headers = set()
@@ -46,14 +45,20 @@ def extract_code(response):
46
  # Skip empty lines at the start
47
  if not cleaned_lines and not line.strip():
48
  continue
49
- # Skip duplicate headers
50
- if "import Mathlib" in line or "import Aesop" in line or "set_option" in line:
51
  if line in seen_headers:
52
  continue
53
  seen_headers.add(line)
 
 
 
54
  cleaned_lines.append(line)
55
 
56
- # Join the lines back together
 
 
 
57
  return '\n'.join(cleaned_lines)
58
  except:
59
  return "None"
 
33
  if not matches:
34
  return "None"
35
 
36
+ # Get the last complete response including the model output
37
  full_content = matches[-1].strip()
38
 
39
  # Clean up any duplicate headers or content
 
40
  lines = full_content.split('\n')
41
  cleaned_lines = []
42
  seen_headers = set()
 
45
  # Skip empty lines at the start
46
  if not cleaned_lines and not line.strip():
47
  continue
48
+ # Skip duplicate headers and "Complete the following..." text
49
+ if any(header in line for header in ["import Mathlib", "import Aesop", "set_option", "Complete the following"]):
50
  if line in seen_headers:
51
  continue
52
  seen_headers.add(line)
53
+ # Skip duplicate goal statements
54
+ if "Goal:" in line and line in cleaned_lines:
55
+ continue
56
  cleaned_lines.append(line)
57
 
58
+ # Remove any trailing "Complete the following..." text
59
+ while cleaned_lines and "Complete the following" in cleaned_lines[-1]:
60
+ cleaned_lines.pop()
61
+
62
  return '\n'.join(cleaned_lines)
63
  except:
64
  return "None"