Execute step

This commit is contained in:
Anton Osika
2023-06-17 14:10:29 +02:00
parent b07fbe1315
commit 5cb6b4539b
2 changed files with 13 additions and 5 deletions

View File

@@ -1,7 +1,9 @@
import re
from typing import List, Tuple
from gpt_engineer.db import DB
def parse_chat(chat): # -> List[Tuple[str, str]]:
def parse_chat(chat) -> List[Tuple[str, str]]:
# Get all ``` blocks
regex = r"```(.*?)```"
@@ -19,7 +21,7 @@ def parse_chat(chat): # -> List[Tuple[str, str]]:
return files
def to_files(chat, workspace):
def to_files(chat: str, workspace: DB):
workspace["all_output.txt"] = chat
files = parse_chat(chat)

View File

@@ -1,8 +1,10 @@
import json
import subprocess
from gpt_engineer.ai import AI
from gpt_engineer.chat_to_files import to_files
from gpt_engineer.db import DBs
from gpt_engineer.chat_to_files import parse_chat
def setup_sys_prompt(dbs):
@@ -98,11 +100,15 @@ def execute_workspace(ai: AI, dbs: DBs):
f"You will get infomation about a codebase that is currently on disk in the folder {dbs.workspace.path}.\n"
"From this you will answer with one code block that includes all the necessary macos terminal commands to "
"a) install dependencies "
"b) run the necessary parts of the codebase to try it."
"b) run the necessary parts of the codebase to try it.\n"
"Do not explain the code, just give the commands.\n"
),
user="Information about the codebase:\n\n" + dbs.workspace["all_output.txt"],
)
command = messages[-1]['content'].strip('```')
[[lang, command]] = parse_chat(messages[-1]['content'])
assert lang in ['', 'bash']
print('Do you want to execute this code?')
print(command)
print()
@@ -125,7 +131,7 @@ STEPS = {
}
# Future steps that can be added:
# improve_files,
# self_reflect_and_improve_files,
# add_tests
# run_tests_and_fix_files,
# improve_based_on_in_file_feedback_comments