pull/8/head
Noah Shinn 2 years ago
parent 2223481bfe
commit 975fc6fcd5

@ -22,7 +22,7 @@ def gpt_completion(
stop_strs: Optional[List[str]] = None, stop_strs: Optional[List[str]] = None,
temperature: float = 0.0, temperature: float = 0.0,
num_comps=1, num_comps=1,
) -> List[str] | str: ) -> Union[List[str], str]:
response = openai.Completion.create( response = openai.Completion.create(
model=model, model=model,
prompt=prompt, prompt=prompt,
@ -48,7 +48,7 @@ def gpt_chat(
max_tokens: int = 256, max_tokens: int = 256,
temperature: float = 0.0, temperature: float = 0.0,
num_comps=1, num_comps=1,
) -> List[str] | str: ) -> Union[List[str], str]:
response = openai.ChatCompletion.create( response = openai.ChatCompletion.create(
model=model, model=model,
messages=[ messages=[

@ -1,6 +1,6 @@
from .generator_utils import gpt_chat, gpt_completion from .generator_utils import gpt_chat, gpt_completion
from typing import Optional, List from typing import Optional, List, Union
PY_SIMPLE_COMPLETION_INSTRUCTION = "# Write the body of this function only." PY_SIMPLE_COMPLETION_INSTRUCTION = "# Write the body of this function only."
PY_REFLEXION_COMPLETION_INSTRUCTION = "You are PythonGPT. You will be given your past function implementation, a series of unit tests, and a hint to change the implementation appropriately. Apply the changes below by writing the body of this function only.\n\n-----" PY_REFLEXION_COMPLETION_INSTRUCTION = "You are PythonGPT. You will be given your past function implementation, a series of unit tests, and a hint to change the implementation appropriately. Apply the changes below by writing the body of this function only.\n\n-----"
@ -64,7 +64,7 @@ def py_generate_func_impl(
self_reflection: Optional[str] = None, self_reflection: Optional[str] = None,
num_comps: int = 1, num_comps: int = 1,
temperature: float = 0.0, temperature: float = 0.0,
) -> str | List[str]: ) -> Union[str, List[str]]:
if strategy != "reflexion" and strategy != "simple": if strategy != "reflexion" and strategy != "simple":
raise ValueError(f"Invalid strategy: given `{strategy}` but expected one of `reflexion` or `simple`") raise ValueError(f"Invalid strategy: given `{strategy}` but expected one of `reflexion` or `simple`")
if strategy == "reflexion" and (prev_func_impl is None or feedback is None or self_reflection is None): if strategy == "reflexion" and (prev_func_impl is None or feedback is None or self_reflection is None):

@ -1 +1 @@
Subproject commit 10aa52640c74ccb7512a7e4cb122a3c1c548ce7f Subproject commit 404c06a5bf6201596b45d28f092aefe017306cd9

File diff suppressed because one or more lines are too long

@ -1,5 +1,5 @@
python main.py \ python main.py \
--run_name "reflexion_ucs_scratch" \ --run_name "reflexion_ucs_with_output2" \
--root_dir "root" \ --root_dir "root" \
--dataset_path ./human-eval/data/HumanEval.jsonl.gz \ --dataset_path ./human-eval/data/HumanEval.jsonl.gz \
--strategy "reflexion-ucs" \ --strategy "reflexion-ucs" \

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save