add code block instruction

main
Noah Shinn 10 months ago
parent f2720b347a
commit 59c84d9854

@ -1,6 +1,5 @@
from generators.model import ModelBase, Message
import random
from parse import parse_code_block, add_code_block
from typing import Union, List, Optional, Callable
@ -155,7 +154,8 @@ def generic_generate_self_reflection(
model: ModelBase,
self_reflection_chat_instruction: str,
self_reflection_completion_instruction: str,
self_reflection_few_shot: Optional[str] = None
add_code_block: Callable[[str], str],
self_reflection_few_shot: Optional[str] = None,
) -> str:
if model.is_chat:
if self_reflection_few_shot is not None:

@ -5,7 +5,7 @@ from .generator_utils import generic_generate_func_impl, generic_generate_intern
from typing import Optional, List, Union
import ast
import re
from parse import parse_code_block, add_code_block
from .parse import parse_code_block, add_code_block
PY_SIMPLE_COMPLETION_INSTRUCTION = "# Write the body of this function only."
PY_REFLEXION_COMPLETION_INSTRUCTION = "You are a Python writing assistant. You will be given your past function implementation, a series of unit tests, and a hint to change the implementation appropriately. Write your full implementation (restate the function signature).\n\n-----"
@ -255,6 +255,7 @@ class PyGenerator(Generator):
model=model,
self_reflection_chat_instruction=PY_SELF_REFLECTION_CHAT_INSTRUCTION,
self_reflection_completion_instruction=PY_SELF_REFLECTION_COMPLETION_INSTRUCTION,
add_code_block=lambda x: add_code_block(x, "python"),
self_reflection_few_shot=PY_SELF_REFLECTION_FEW_SHOT
)

@ -1,7 +1,7 @@
from generators.model import ModelBase
from .generator_types import Generator
from .generator_utils import generic_generate_func_impl, generic_generate_internal_tests, generic_generate_self_reflection
from parse import parse_code_block, add_code_block
from .parse import parse_code_block, add_code_block
from typing import List, Optional, Union
@ -149,6 +149,7 @@ class RsGenerator(Generator):
model=model,
self_reflection_chat_instruction=RS_SELF_REFLECTION_CHAT_INSTRUCTION,
self_reflection_completion_instruction=RS_SELF_REFLECTION_COMPLETION_INSTRUCTION,
add_code_block=lambda x: add_code_block(x, "rust"),
self_reflection_few_shot=RS_SELF_REFLECTION_FEW_SHOT,
)

Loading…
Cancel
Save