mirror of
https://github.com/GammaTauAI/reflexion-human-eval
synced 2024-11-16 00:12:59 +00:00
leet shape code
This commit is contained in:
parent
963d1842b0
commit
5fd6ff89c6
@ -1,11 +1,18 @@
|
||||
from .py_executor import PyExecutor
|
||||
from .rs_executor import RsExecutor
|
||||
from .py_executor import PyExecutor, PyLeetExecutor
|
||||
from .rs_executor import RsExecutor, RsLeetExecutor
|
||||
from .executor_types import Executor
|
||||
|
||||
def executor_factory(lang: str) -> Executor:
|
||||
|
||||
def executor_factory(lang: str, is_leet: bool = False) -> Executor:
|
||||
if lang == "py" or lang == "python":
|
||||
return PyExecutor()
|
||||
if is_leet:
|
||||
return PyLeetExecutor()
|
||||
else:
|
||||
return PyExecutor()
|
||||
elif lang == "rs" or lang == "rust":
|
||||
return RsExecutor()
|
||||
if is_leet:
|
||||
return RsLeetExecutor()
|
||||
else:
|
||||
return RsExecutor()
|
||||
else:
|
||||
raise ValueError(f"Invalid language for executor: {lang}")
|
||||
|
@ -76,6 +76,10 @@ check({name})
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
class PyLeetExecutor(PyExecutor):
|
||||
def evaluate(self, name: str, func: str, test: str, timeout: int = 5) -> bool:
|
||||
raise NotImplementedError
|
||||
|
||||
def get_call_str(assert_statement: str) -> str:
|
||||
call_str = ast.parse(assert_statement).body[0].test.left # type: ignore
|
||||
return astunparse.unparse(call_str).strip()
|
||||
|
@ -207,6 +207,10 @@ class RsExecutor(Executor):
|
||||
print("Passed eval", flush=True)
|
||||
return len(errs) == 0
|
||||
|
||||
class RsLeetExecutor(RsExecutor):
|
||||
def evaluate(self, name: str, func: str, test: str, timeout: int = 5) -> bool:
|
||||
raise NotImplementedError("Not implemented for Rust")
|
||||
|
||||
|
||||
assert_no_panic = r"""
|
||||
macro_rules! assert_eq_nopanic {
|
||||
|
Loading…
Reference in New Issue
Block a user