From 3fea70b35dbb3995df7fa3678aa42f80bd92acf9 Mon Sep 17 00:00:00 2001 From: LeonOstrez Date: Fri, 28 Jul 2023 12:53:03 +0200 Subject: [PATCH] forward messages through steps --- euclid/database/database.py | 1 - euclid/main.py | 9 ++-- .../prompts/architecture/technologies.prompt | 2 +- euclid/steps/architecture/architecture.py | 49 +++++++++++++++++++ .../project_description.py | 8 +-- euclid/steps/user_stories/user_stories.py | 8 +-- euclid/steps/user_tasks/user_tasks.py | 8 +-- 7 files changed, 70 insertions(+), 15 deletions(-) create mode 100644 euclid/steps/architecture/architecture.py diff --git a/euclid/database/database.py b/euclid/database/database.py index 3191aa8..f509994 100644 --- a/euclid/database/database.py +++ b/euclid/database/database.py @@ -129,7 +129,6 @@ def save_progress(app_id, step, data): conn.close() - def get_apps_by_id(app_id): conn = create_connection() cursor = conn.cursor() diff --git a/euclid/main.py b/euclid/main.py index 166c689..58f3d3c 100644 --- a/euclid/main.py +++ b/euclid/main.py @@ -9,6 +9,7 @@ from logger.logger import logger from steps.project_description.project_description import get_project_description from steps.user_stories.user_stories import get_user_stories from steps.user_tasks.user_tasks import get_user_tasks +from steps.architecture.architecture import get_architecture def init(): @@ -24,12 +25,12 @@ def init(): if __name__ == "__main__": args = init() - high_level_summary = get_project_description(args) + high_level_summary, high_level_messages = get_project_description(args) - user_stories = get_user_stories(high_level_summary, args) + user_stories, user_stories_messages = get_user_stories(high_level_summary, args) - user_tasks = get_user_tasks(user_stories, args) + user_tasks, user_tasks_messages = get_user_tasks(user_stories, args) - # get architecture plan + architecture, architecture_messages = get_architecture(high_level_summary, user_stories, user_tasks, args) # development diff --git a/euclid/prompts/architecture/technologies.prompt b/euclid/prompts/architecture/technologies.prompt index 7a89fe0..a338524 100644 --- a/euclid/prompts/architecture/technologies.prompt +++ b/euclid/prompts/architecture/technologies.prompt @@ -1,4 +1,4 @@ -You are working in a software development agency and a project manager approached you telling you that you're assigned to work on a new project. You are working on a web app called Euclid and you need to create specifications on what technologies should be used in this project. +You are working in a software development agency and a project manager approached you telling you that you're assigned to work on a new project. You are working on a {{app_type}} called Euclid and you need to create specifications on what technologies should be used in this project. Here is a high level description of Euclid: ``` diff --git a/euclid/steps/architecture/architecture.py b/euclid/steps/architecture/architecture.py new file mode 100644 index 0000000..c1e4d82 --- /dev/null +++ b/euclid/steps/architecture/architecture.py @@ -0,0 +1,49 @@ +# user_stories.py +import json +from termcolor import colored + +from utils.utils import execute_step, split_into_bullets, find_role_from_step, generate_app_data +from database.database import save_progress, get_progress_steps +from logger.logger import logger +from prompts.prompts import get_additional_info_from_user, execute_chat_prompt + + +def get_architecture(high_level_summary, user_stories, user_tasks, args): + current_step = 'architecture' + role = find_role_from_step(current_step) + # If this app_id already did this step, just get all data from DB and don't ask user again + steps = get_progress_steps(args['app_id'], current_step) + if steps and not execute_step(args['step'], current_step): + first_step = steps[0] + data = json.loads(first_step['data']) + + architecture = data.get('architecture') + + message = f"Architecture already done for this app_id: {args['app_id']}. Moving to next step..." + print(colored(message, "green")) + logger.info(message) + return architecture, data.get('messages') + + # ARCHITECTURE + print(colored(f"Planning project architecture...\n", "green")) + logger.info(f"Planning project architecture...") + + architecture, architecture_messages = execute_chat_prompt('architecture/technologies.prompt', + {'prompt': high_level_summary, + 'user_stories': user_stories, + 'user_tasks': user_tasks, + 'app_type': args['app_type']}, + current_step) + + architecture = get_additional_info_from_user(split_into_bullets(architecture), role) + + logger.info(f"Final architecture: {architecture}") + + save_progress(args['app_id'], current_step, { + "messages": architecture_messages, + "architecture": architecture, + "app_data": generate_app_data(args) + }) + + return architecture, architecture_messages + # ARCHITECTURE END diff --git a/euclid/steps/project_description/project_description.py b/euclid/steps/project_description/project_description.py index 87ec11d..7411fca 100644 --- a/euclid/steps/project_description/project_description.py +++ b/euclid/steps/project_description/project_description.py @@ -8,6 +8,7 @@ from utils.utils import execute_step, generate_app_data from prompts.prompts import ask_for_app_type, ask_for_main_app_definition, get_additional_info_from_openai, \ generate_messages_from_description, execute_chat_prompt + def get_project_description(args): current_step = 'project_description' # If this app_id already did this step, just get all data from DB and don't ask user again @@ -24,7 +25,7 @@ def get_project_description(args): print(colored(message, "green")) logger.info(message) - return summary + return summary, data.get('messages') # PROJECT DESCRIPTION args['app_type'] = ask_for_app_type() @@ -42,7 +43,8 @@ def get_project_description(args): current_step) save_progress(args['app_id'], current_step, - {"messages": high_level_messages, "summary": high_level_summary, "app_data": generate_app_data(args)}) + {"messages": high_level_messages, "summary": high_level_summary, "app_data": generate_app_data(args) + }) - return high_level_summary + return high_level_summary, high_level_messages # PROJECT DESCRIPTION END diff --git a/euclid/steps/user_stories/user_stories.py b/euclid/steps/user_stories/user_stories.py index 4a92421..181188e 100644 --- a/euclid/steps/user_stories/user_stories.py +++ b/euclid/steps/user_stories/user_stories.py @@ -25,7 +25,7 @@ def get_user_stories(summary, args): message = f"User stories already done for this app_id: {args['app_id']}. Moving to next step..." print(colored(message, "green")) logger.info(message) - return user_stories + return user_stories, data.get('messages') # USER STORIES print(colored(f"Generating user stories...\n", "green")) @@ -40,7 +40,9 @@ def get_user_stories(summary, args): logger.info(f"Final user stories: {user_stories}") - save_progress(args['app_id'], current_step, {"user_stories": user_stories, "app_data": generate_app_data(args)}) + save_progress(args['app_id'], current_step, { + "messages": user_stories_messages, "user_stories": user_stories, "app_data": generate_app_data(args) + }) - return user_stories + return user_stories, user_stories_messages # USER STORIES END \ No newline at end of file diff --git a/euclid/steps/user_tasks/user_tasks.py b/euclid/steps/user_tasks/user_tasks.py index 76f213f..b5ce26c 100644 --- a/euclid/steps/user_tasks/user_tasks.py +++ b/euclid/steps/user_tasks/user_tasks.py @@ -25,7 +25,7 @@ def get_user_tasks(summary, args): message = f"User tasks already done for this app_id: {args['app_id']}. Moving to next step..." print(colored(message, "green")) logger.info(message) - return summary + return summary, data.get('messages') # USER TASKS print(colored(f"Generating user tasks...\n", "green")) @@ -40,7 +40,9 @@ def get_user_tasks(summary, args): logger.info(f"Final user tasks: {user_tasks}") - save_progress(args['app_id'], current_step, {"user_tasks": user_tasks, "app_data": generate_app_data(args)}) + save_progress(args['app_id'], current_step, { + "messages": user_tasks_messages,"user_tasks": user_tasks, "app_data": generate_app_data(args) + }) - return user_tasks + return user_tasks, user_tasks_messages # USER TASKS END \ No newline at end of file