Make gpt-engineer pip installable/runnable (#60)

This commit is contained in:
Jack Eadie
2023-06-16 21:25:29 +10:00
committed by GitHub
parent 12cb93fc7a
commit 6f8e976a42
8 changed files with 59 additions and 23 deletions

View File

@@ -0,0 +1,27 @@
import re
def parse_chat(chat): # -> List[Tuple[str, str]]:
# Get all ``` blocks
regex = r"```(.*?)```"
matches = re.finditer(regex, chat, re.DOTALL)
files = []
for match in matches:
path = match.group(1).split("\n")[0]
# Get the code
code = match.group(1).split("\n")[1:]
code = "\n".join(code)
# Add the file to the list
files.append((path, code))
return files
def to_files(chat, workspace):
workspace["all_output.txt"] = chat
files = parse_chat(chat)
for file_name, file_content in files:
workspace[file_name] = file_content