Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve execution step #123

Merged
merged 1 commit into from
Jun 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions gpt_engineer/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def gen_spec(ai: AI, dbs: DBs):
'''
Generate a spec from the main prompt + clarifications and save the results to the workspace
'''
messages = [ai.fsystem(setup_sys_prompt(dbs)), ai.fsystem(f"Main prompt: {dbs.input['main_prompt']}")]
messages = [ai.fsystem(setup_sys_prompt(dbs)), ai.fsystem(f"Instructions: {dbs.input['main_prompt']}")]

messages = ai.next(messages, dbs.identity['spec'])
messages = ai.next(messages, dbs.identity['respec'])
Expand Down Expand Up @@ -97,10 +97,11 @@ def run_clarified(ai: AI, dbs: DBs):
def execute_workspace(ai: AI, dbs: DBs):
messages = ai.start(
system=(
f"You will get infomation about a codebase that is currently on disk in the folder {dbs.workspace.path}.\n"
f"You will get information about a codebase that is currently on disk in the current folder.\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.\n"
"b) run all necessary parts of the codebase (in parallell if necessary).\n"
"Do not install globally. Do not use sudo.\n"
"Do not explain the code, just give the commands.\n"
),
user="Information about the codebase:\n\n" + dbs.workspace["all_output.txt"],
Expand All @@ -109,6 +110,8 @@ def execute_workspace(ai: AI, dbs: DBs):
[[lang, command]] = parse_chat(messages[-1]['content'])
assert lang in ['', 'bash', 'sh']

dbs.workspace['run.sh'] = command

print('Do you want to execute this code?')
print(command)
print()
Expand All @@ -119,7 +122,9 @@ def execute_workspace(ai: AI, dbs: DBs):
return messages
print('Executing the code...')
print()
subprocess.run(command, shell=True)

# Run the subprocess in dbs.workspace.path
subprocess.run('bash run.sh', shell=True, cwd=dbs.workspace.path)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @AntonOsika

I think I am missing something here, are we forcing the creation of a run.sh file somewhere?

Copy link
Contributor

@jebarpg jebarpg Jun 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need an environment flag to choose which shell to use for this. something like
@patillacode @AntonOsika

import subprocess
import psutil
import os
#https://github.com/giampaolo/psutil
p = psutil.Process(os.getppid())
env = p.environ()
print(env)
if 'COMSPEC' in env:
    subprocess.run('cmd run.bat', shell=True, cwd=dbs.workspace.path)
if 'SHELL' in env:
    subprocess.run(f'{env['SHELL']} run.sh', shell=True, cwd=dbs.workspace.path) #{env['SHELL']}will return the shell like this '/bin/bash'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I change this in my own build? Super unfamiliar with github and the like, but I'm trying to run gp-engineer through vscode terminal and conda env.

return messages


Expand All @@ -128,6 +133,7 @@ def execute_workspace(ai: AI, dbs: DBs):
'default': [gen_spec, pre_unit_tests, run_clarified],
'simple': [run, execute_workspace],
'clarify': [clarify, run_clarified],
'execute_only': [execute_workspace],
}

# Future steps that can be added:
Expand Down