add unit_tests and spec/respec

This commit is contained in:
Emil Ahlbäck
2023-06-17 13:37:45 +02:00
parent 03d8fff5d2
commit fa1df72bf3
5 changed files with 54 additions and 5 deletions

View File

@@ -50,13 +50,42 @@ def clarify(ai: AI, dbs: DBs):
return messages
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.next(messages, dbs.identity['spec'])
messages = ai.next(messages, dbs.identity['respec'])
messages = ai.next(messages, dbs.identity['spec'])
dbs.memory['specification'] = messages[-1]['content']
return messages
def pre_unit_tests(ai: AI, dbs: DBs):
'''
Generate unit tests based on the specification, that should work.
'''
messages = [ai.fsystem(setup_sys_prompt(dbs)), ai.fsystem(f"Main prompt: {dbs.input['main_prompt']}"), ai.fsystem(f"Specification:\n\n{dbs.memory['specification']}")]
messages = ai.next(messages, dbs.identity['unit_tests'])
dbs.memory['unit_tests'] = messages[-1]['content']
return messages
def run_clarified(ai: AI, dbs: DBs):
# get the messages from previous step
messages = json.loads(dbs.logs[clarify.__name__])
messages = [
ai.fsystem(setup_sys_prompt(dbs)),
] + messages[1:]
ai.fsystem(f"Main prompt: {dbs.input['main_prompt']}"),
ai.fsystem(f"Specification:\n\n{dbs.memory['specification']}"),
ai.fsystem(f"Unit tests:\n\n{dbs.memory['unit_tests']}"),
]
messages = ai.next(messages, dbs.identity['use_qa'])
to_files(messages[-1]['content'], dbs.workspace)
return messages
@@ -65,6 +94,7 @@ def run_clarified(ai: AI, dbs: DBs):
# Different configs of what steps to run
STEPS = {
'default': [run],
'unit_tests': [gen_spec, pre_unit_tests, run_clarified],
'clarify': [clarify, run_clarified],
}
@@ -72,4 +102,4 @@ STEPS = {
# improve_files,
# add_tests
# run_tests_and_fix_files,
# improve_based_on_in_file_feedback_comments
# improve_based_on_in_file_feedback_comments