mirror of
https://github.com/aljazceru/gpt-engineer.git
synced 2025-12-17 12:45:26 +01:00
Execute step
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
import re
|
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
|
# Get all ``` blocks
|
||||||
regex = r"```(.*?)```"
|
regex = r"```(.*?)```"
|
||||||
|
|
||||||
@@ -19,7 +21,7 @@ def parse_chat(chat): # -> List[Tuple[str, str]]:
|
|||||||
return files
|
return files
|
||||||
|
|
||||||
|
|
||||||
def to_files(chat, workspace):
|
def to_files(chat: str, workspace: DB):
|
||||||
workspace["all_output.txt"] = chat
|
workspace["all_output.txt"] = chat
|
||||||
|
|
||||||
files = parse_chat(chat)
|
files = parse_chat(chat)
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import json
|
import json
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from gpt_engineer.ai import AI
|
from gpt_engineer.ai import AI
|
||||||
from gpt_engineer.chat_to_files import to_files
|
from gpt_engineer.chat_to_files import to_files
|
||||||
from gpt_engineer.db import DBs
|
from gpt_engineer.db import DBs
|
||||||
|
from gpt_engineer.chat_to_files import parse_chat
|
||||||
|
|
||||||
|
|
||||||
def setup_sys_prompt(dbs):
|
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"
|
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 "
|
"From this you will answer with one code block that includes all the necessary macos terminal commands to "
|
||||||
"a) install dependencies "
|
"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"],
|
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('Do you want to execute this code?')
|
||||||
print(command)
|
print(command)
|
||||||
print()
|
print()
|
||||||
@@ -125,7 +131,7 @@ STEPS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Future steps that can be added:
|
# Future steps that can be added:
|
||||||
# improve_files,
|
# self_reflect_and_improve_files,
|
||||||
# add_tests
|
# add_tests
|
||||||
# run_tests_and_fix_files,
|
# run_tests_and_fix_files,
|
||||||
# improve_based_on_in_file_feedback_comments
|
# improve_based_on_in_file_feedback_comments
|
||||||
|
|||||||
Reference in New Issue
Block a user