diff --git a/gpt_engineer/ai.py b/gpt_engineer/ai.py index 10351a6..619bda0 100644 --- a/gpt_engineer/ai.py +++ b/gpt_engineer/ai.py @@ -26,6 +26,9 @@ class AI: def fuser(self, msg): return {"role": "user", "content": msg} + def fassistant(self, msg): + return {"role": "assistant", "content": msg} + def next(self, messages: list[dict[str, str]], prompt=None): if prompt: diff --git a/gpt_engineer/steps.py b/gpt_engineer/steps.py index b82af8a..88115da 100644 --- a/gpt_engineer/steps.py +++ b/gpt_engineer/steps.py @@ -166,9 +166,23 @@ def gen_entrypoint(ai, dbs): user="Information about the codebase:\n\n" + dbs.workspace["all_output.txt"], ) print() - [[lang, command]] = parse_chat(messages[-1]["content"]) - assert lang in ["", "bash", "sh"] - dbs.workspace["run.sh"] = command + + blocks = parse_chat(messages[-1]["content"]) + for lang, _ in blocks: + assert lang in ["", "bash", "sh"], "Generated entrypoint command that was not bash" + + dbs.workspace["run.sh"] = "\n".join(block for lang, block in blocks) + return messages + +def use_feedback(ai: AI, dbs: DBs): + messages = [ + ai.fsystem(setup_sys_prompt(dbs)), + ai.fuser(f"Instructions: {dbs.input['main_prompt']}"), + ai.fassistant(dbs.workspace["all_output.txt"]), + ai.fsystem(dbs.identity["use_feedback"]), + ] + messages = ai.next(messages, dbs.memory['feedback']) + to_files(messages[-1]["content"], dbs.workspace) return messages @@ -180,6 +194,7 @@ STEPS = { "clarify": [clarify, gen_clarified_code, execute_workspace], "respec": [gen_spec, respec, gen_unit_tests, gen_code, execute_workspace], "execute_only": [execute_entrypoint], + "use_feedback": [use_feedback], } # Future steps that can be added: diff --git a/identity/use_feedback b/identity/use_feedback new file mode 100644 index 0000000..e69de29