Spaces:
Running
Running
small fix
Browse files- generate.py +7 -3
generate.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import os
|
| 2 |
import re
|
|
|
|
| 3 |
from llms import build_prompt, get_completion, PROMPT_TEMPLATE, SYSTEM_PROMPT
|
| 4 |
|
| 5 |
|
|
@@ -25,8 +26,11 @@ def extract_code(completion: str) -> str:
|
|
| 25 |
if code_block:
|
| 26 |
return code_block.group(1)
|
| 27 |
|
| 28 |
-
def get_solution_file_path(
|
| 29 |
-
"""Returns the path to the solution file for the given day and model."""
|
|
|
|
|
|
|
|
|
|
| 30 |
day_str = f"{day:02d}"
|
| 31 |
return f"day{day_str}/solution_{model}.py"
|
| 32 |
|
|
@@ -57,7 +61,7 @@ if __name__ == "__main__":
|
|
| 57 |
print("-" * 80)
|
| 58 |
print(f"Generating code for {provider} {model}")
|
| 59 |
|
| 60 |
-
if os.path.exists(get_solution_file_path(
|
| 61 |
print(f"Skipping {provider} {model} for day {day} because it already exists")
|
| 62 |
continue
|
| 63 |
|
|
|
|
| 1 |
import os
|
| 2 |
import re
|
| 3 |
+
from typing import Optional
|
| 4 |
from llms import build_prompt, get_completion, PROMPT_TEMPLATE, SYSTEM_PROMPT
|
| 5 |
|
| 6 |
|
|
|
|
| 26 |
if code_block:
|
| 27 |
return code_block.group(1)
|
| 28 |
|
| 29 |
+
def get_solution_file_path(model: str, day: Optional[int] = None):
|
| 30 |
+
"""Returns the path to the solution file for the given day and model. If day is None, returns the path to the solution file only."""
|
| 31 |
+
if day is None:
|
| 32 |
+
return f"solution_{model}.py"
|
| 33 |
+
|
| 34 |
day_str = f"{day:02d}"
|
| 35 |
return f"day{day_str}/solution_{model}.py"
|
| 36 |
|
|
|
|
| 61 |
print("-" * 80)
|
| 62 |
print(f"Generating code for {provider} {model}")
|
| 63 |
|
| 64 |
+
if os.path.exists(get_solution_file_path(model=model, day=day)):
|
| 65 |
print(f"Skipping {provider} {model} for day {day} because it already exists")
|
| 66 |
continue
|
| 67 |
|