Skip to content

Commit

Permalink
Execute step
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonOsika committed Jun 17, 2023
1 parent b07fbe1 commit 5cb6b45
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 4 additions & 2 deletions gpt_engineer/chat_to_files.py
Original file line number Diff line number Diff line change
@@ -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"```(.*?)```"

Expand All @@ -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)
Expand Down
12 changes: 9 additions & 3 deletions gpt_engineer/steps.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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()
Expand All @@ -125,7 +131,7 @@ def execute_workspace(ai: AI, dbs: DBs):
}

# 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

0 comments on commit 5cb6b45

Please sign in to comment.