mirror of
https://github.com/aljazceru/gpt-engineer.git
synced 2025-12-17 20:55:09 +01:00
Clean up clarifying question part
This commit is contained in:
37
steps.py
37
steps.py
@@ -3,6 +3,7 @@ from dataclasses import dataclass
|
||||
from typing import Callable
|
||||
from ai import AI
|
||||
from chat_to_files import to_files
|
||||
import json
|
||||
|
||||
from db import DBs
|
||||
from db import DB
|
||||
@@ -15,36 +16,44 @@ def setup(ai: AI, dbs: DBs):
|
||||
to_files(messages[-1]['content'], dbs.workspace)
|
||||
return messages
|
||||
|
||||
def run_clarified(ai: AI, dbs: DBs):
|
||||
messages = ai.start(setup_sys_prompt(dbs), dbs.input['main_prompt'])
|
||||
to_files(messages[-1]['content'], DB(str(dbs.workspace.path)+'_clarified'))
|
||||
return messages
|
||||
|
||||
def clarify(ai: AI, dbs: DBs):
|
||||
messages = [ai.fsystem(dbs.identity['qa'])]
|
||||
user = dbs.input['main_prompt']
|
||||
while True:
|
||||
messages = ai.next(messages, user)
|
||||
|
||||
if messages[-1]['content'].strip().lower() == 'no':
|
||||
break
|
||||
|
||||
print()
|
||||
user = input('Answer: ')
|
||||
if not user or user == 'q':
|
||||
break
|
||||
|
||||
user += '\nIs anything else unclear? Please ask more questions until instructions are sufficient to write the code.'
|
||||
user += '\n\nIs anything else unclear? If everything is sufficiently clear to write the code, just answer "no".'
|
||||
|
||||
# TOOD: Stop using clarify prompt. Just append questions and answers to the main prompt.
|
||||
prompt = dbs.identity['clarify']
|
||||
messages = ai.next([ai.fsystem(prompt)] + messages[1:], prompt)
|
||||
dbs.memory['clarified_prompt'] = 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:]
|
||||
)
|
||||
messages = ai.next(messages, dbs.identity['use_qa'])
|
||||
to_files(messages[-1]['content'], DB(str(dbs.workspace.path)+'_clarified'))
|
||||
return messages
|
||||
|
||||
|
||||
# STEPS: List[Callable[[AI, DBs], List]] = [
|
||||
STEPS=[
|
||||
setup,
|
||||
# clarify,
|
||||
# run_clarified
|
||||
# to_files,
|
||||
# setup,
|
||||
clarify,
|
||||
run_clarified
|
||||
# improve_files,
|
||||
# run_tests,
|
||||
# ImproveBasedOnHumanComments
|
||||
|
||||
Reference in New Issue
Block a user