Spaces:
Running
Running
fix small bug
Browse files- generate.py +7 -5
generate.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 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,15 +26,17 @@ def extract_code(completion: str) -> str:
|
|
| 26 |
if code_block:
|
| 27 |
return code_block.group(1)
|
| 28 |
|
| 29 |
-
def get_solution_file_path(model: str, day: Optional[str
|
| 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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
if isinstance(day, str):
|
| 33 |
day = int(day)
|
| 34 |
-
day_str = f"{day:02d}"
|
| 35 |
|
| 36 |
-
|
| 37 |
-
return f"solution_{model}.py"
|
| 38 |
|
| 39 |
return f"day{day_str}/solution_{model}.py"
|
| 40 |
|
|
|
|
| 1 |
import os
|
| 2 |
import re
|
| 3 |
+
from typing import Optional, Union
|
| 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[Union[str, 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 |
|
| 32 |
+
if day is None:
|
| 33 |
+
return f"solution_{model}.py"
|
| 34 |
+
|
| 35 |
+
# We want it formatted properly, so we convert to int and back if its already a string for convenience
|
| 36 |
if isinstance(day, str):
|
| 37 |
day = int(day)
|
|
|
|
| 38 |
|
| 39 |
+
day_str = f"{day:02d}"
|
|
|
|
| 40 |
|
| 41 |
return f"day{day_str}/solution_{model}.py"
|
| 42 |
|