Always generate entrypoint

This commit is contained in:
Anton Osika
2023-06-17 21:01:30 +02:00
parent 903a8905cb
commit 8ac2cd81b9
2 changed files with 28 additions and 18 deletions

1
.gitignore vendored
View File

@@ -36,3 +36,4 @@ archive
# any log file # any log file
*log.txt *log.txt
todo

View File

@@ -95,6 +95,29 @@ def run_clarified(ai: AI, dbs: DBs):
def execute_workspace(ai: AI, dbs: DBs): def execute_workspace(ai: AI, dbs: DBs):
messages = gen_entrypoint(ai, dbs)
execute_entrypoint(ai, dbs)
return messages
def execute_entrypoint(ai, dbs):
command = dbs.workspace['run.sh']
print('Do you want to execute this code?')
print()
print(command)
print()
print('If yes, press enter. If no, type "no"')
print()
if input() == 'no':
print('Ok, not executing the code.')
print('Executing the code...')
print()
subprocess.run('bash run.sh', shell=True, cwd=dbs.workspace.path)
return []
def gen_entrypoint(ai, dbs):
messages = ai.start( messages = ai.start(
system=( system=(
f"You will get information about a codebase that is currently on disk in the current folder.\n" f"You will get information about a codebase that is currently on disk in the current folder.\n"
@@ -106,34 +129,20 @@ def execute_workspace(ai: AI, dbs: DBs):
), ),
user="Information about the codebase:\n\n" + dbs.workspace["all_output.txt"], user="Information about the codebase:\n\n" + dbs.workspace["all_output.txt"],
) )
print()
[[lang, command]] = parse_chat(messages[-1]['content']) [[lang, command]] = parse_chat(messages[-1]['content'])
assert lang in ['', 'bash', 'sh'] assert lang in ['', 'bash', 'sh']
dbs.workspace['run.sh'] = command dbs.workspace['run.sh'] = command
print('Do you want to execute this code?')
print(command)
print()
print('If yes, press enter. If no, type "no"')
print()
if input() == 'no':
print('Ok, not executing the code.')
return messages
print('Executing the code...')
print()
# Run the subprocess in dbs.workspace.path
subprocess.run('bash run.sh', shell=True, cwd=dbs.workspace.path)
return messages return messages
# Different configs of what steps to run # Different configs of what steps to run
STEPS = { STEPS = {
'default': [gen_spec, pre_unit_tests, run_clarified, execute_workspace], 'default': [gen_spec, pre_unit_tests, run_clarified, execute_workspace],
'benchmark': [gen_spec, pre_unit_tests, run_clarified, gen_entrypoint],
'simple': [run, execute_workspace], 'simple': [run, execute_workspace],
'clarify': [clarify, run_clarified], 'clarify': [clarify, run_clarified, gen_entrypoint],
'execute_only': [execute_workspace], 'execute_only': [execute_entrypoint],
} }
# Future steps that can be added: # Future steps that can be added: