From aed2544bb6f448c4e2cdc5f0b281300f2bdc9fba Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Sat, 18 Nov 2023 08:53:54 -0800 Subject: [PATCH] Revert "add separate counter for development steps in model" This reverts commit a7cd3d338a80b723a9b7fc0b988f99f243ab8f3b. --- pilot/.env.example | 2 +- pilot/database/database.py | 11 ++--------- pilot/database/models/development_steps.py | 3 --- pilot/helpers/AgentConvo.py | 4 ++-- pilot/test/database/test_file_snapshot.py | 2 +- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/pilot/.env.example b/pilot/.env.example index 5f90b09db3..78cada5b88 100644 --- a/pilot/.env.example +++ b/pilot/.env.example @@ -12,7 +12,7 @@ OPENROUTER_API_KEY= # In case of Azure/OpenRouter endpoint, change this to your deployed model name MODEL_NAME=gpt-4-1106-preview # MODEL_NAME=gpt-4 -# MODEL_NAME=gpt-3.5-turbo-16k +# MODEL_NAME=openai/gpt-3.5-turbo-16k MAX_TOKENS=8192 # Folders which shouldn't be tracked in workspace (useful to ignore folders created by compiler) diff --git a/pilot/database/database.py b/pilot/database/database.py index d2620d8d8e..35f67f54e9 100644 --- a/pilot/database/database.py +++ b/pilot/database/database.py @@ -1,6 +1,6 @@ from playhouse.shortcuts import model_to_dict from utils.style import color_yellow, color_red -from peewee import DoesNotExist, IntegrityError, fn +from peewee import DoesNotExist, IntegrityError from functools import reduce import operator import psycopg2 @@ -272,12 +272,6 @@ def hash_and_save_step(Model, app_id, unique_data_fields, data_fields, message): def save_development_step(project, prompt_path, prompt_data, messages, llm_response, exception=None): - last_step_record = (DevelopmentSteps - .select(fn.MAX(DevelopmentSteps.dev_step_number)) - .where(DevelopmentSteps.app == project.args['app_id']) - .scalar() or 0) - dev_step_number = last_step_record + 1 - data_fields = { 'messages': messages, 'llm_response': llm_response, @@ -285,8 +279,7 @@ def save_development_step(project, prompt_path, prompt_data, messages, llm_respo 'prompt_data': {} if prompt_data is None else {k: v for k, v in prompt_data.items() if k not in PROMPT_DATA_TO_IGNORE and not callable(v)}, 'llm_req_num': project.llm_req_num, - 'token_limit_exception_raised': exception, - 'dev_step_number': dev_step_number + 'token_limit_exception_raised': exception } unique_data = { diff --git a/pilot/database/models/development_steps.py b/pilot/database/models/development_steps.py index 0225c46b66..783c0f3af4 100644 --- a/pilot/database/models/development_steps.py +++ b/pilot/database/models/development_steps.py @@ -7,8 +7,6 @@ from playhouse.postgres_ext import BinaryJSONField class DevelopmentSteps(BaseModel): - # todo this needs refactoring. previous_step is self-referential foreign key and id is auto-incrementing primary - # key for all apps because of that dev_step_number is added to keep track of dev steps for each app individually id = AutoField() # This will serve as the primary key app = ForeignKeyField(App, on_delete='CASCADE') prompt_path = TextField(null=True) @@ -25,7 +23,6 @@ class DevelopmentSteps(BaseModel): prompt_data = JSONField(null=True) previous_step = ForeignKeyField('self', null=True, column_name='previous_step') - dev_step_number = IntegerField() high_level_step = CharField(null=True) class Meta: diff --git a/pilot/helpers/AgentConvo.py b/pilot/helpers/AgentConvo.py index f7850585ee..cd08db9a22 100644 --- a/pilot/helpers/AgentConvo.py +++ b/pilot/helpers/AgentConvo.py @@ -59,7 +59,7 @@ class AgentConvo: development_step = get_saved_development_step(self.agent.project) if development_step is not None and self.agent.project.skip_steps: # if we do, use it - print(color_yellow(f'Restoring development step with id {development_step.dev_step_number}')) + print(color_yellow(f'Restoring development step with id {development_step.id}')) self.agent.project.checkpoints['last_development_step'] = development_step self.agent.project.restore_files(development_step.id) response = development_step.llm_response @@ -240,7 +240,7 @@ class AgentConvo: print_msg = capitalize_first_word_with_underscores(self.high_level_step) if self.log_to_user: if self.agent.project.checkpoints['last_development_step'] is not None: - dev_step_msg = f'\nDev step {str(self.agent.project.checkpoints["last_development_step"].dev_step_number)}\n' + dev_step_msg = f'\nDev step {str(self.agent.project.checkpoints["last_development_step"])}\n' print(color_yellow_bold(dev_step_msg), end='') logger.info(dev_step_msg) print(f"\n{content}\n", type='local') diff --git a/pilot/test/database/test_file_snapshot.py b/pilot/test/database/test_file_snapshot.py index 3ca3b7bb00..4e1e26cbbf 100644 --- a/pilot/test/database/test_file_snapshot.py +++ b/pilot/test/database/test_file_snapshot.py @@ -103,7 +103,7 @@ def test_create_tables(database): def test_file_snapshot(content, expected_content): user = User.create(email="", password="") app = App.create(user=user) - step = DevelopmentSteps.create(app=app, llm_response={}, dev_step_number=1) + step = DevelopmentSteps.create(app=app, llm_response={}) file = File.create(app=app, name="test", path="test", full_path="test") fs = FileSnapshot.create(