fix storing of features to database

pull/369/head
LeonOstrez 3 years ago
parent eb6f42c826
commit 4bc56b0e63

@ -381,6 +381,7 @@ def delete_subsequent_steps(Model, app, step):
subsequent_step.delete_instance()
if Model == DevelopmentSteps:
FileSnapshot.delete().where(FileSnapshot.development_step == subsequent_step).execute()
Feature.delete().where(Feature.previous_step == subsequent_step).execute()
def get_all_connected_steps(step, previous_step_field_name):
@ -424,10 +425,10 @@ def save_file_description(project, path, name, description):
.execute())
def save_feature(app_id, summary, messages):
def save_feature(app_id, summary, messages, previous_step):
try:
app = get_app(app_id)
feature = Feature.create(app=app, summary=summary, messages=messages)
feature = Feature.create(app=app, summary=summary, messages=messages, previous_step=previous_step)
return feature
except DoesNotExist:
raise ValueError(f"No app with id: {app_id}")
@ -437,7 +438,10 @@ def get_features_by_app_id(app_id):
try:
app = get_app(app_id)
features = Feature.select().where(Feature.app == app).order_by(Feature.created_at)
return [model_to_dict(feature) for feature in features]
features_dict = [model_to_dict(feature) for feature in features]
# return only 'summary' because we store all prompt_data to DB
return [{'summary': feature['summary']} for feature in features_dict]
except DoesNotExist:
raise ValueError(f"No app with id: {app_id}")

@ -2,6 +2,7 @@ from peewee import ForeignKeyField, CharField, BooleanField, DateTimeField
from database.config import DATABASE_TYPE
from database.models.components.base_models import BaseModel
from database.models.app import App
from database.models.development_steps import DevelopmentSteps
from database.models.components.sqlite_middlewares import JSONField
from playhouse.postgres_ext import BinaryJSONField
@ -15,5 +16,6 @@ class Feature(BaseModel):
else:
messages = JSONField(null=True)
previous_step = ForeignKeyField(DevelopmentSteps, column_name='previous_step')
completed = BooleanField(default=False)
completed_at = DateTimeField(null=True)

@ -94,6 +94,11 @@ class TechLead(Agent):
self.project.feature_summary = llm_response
save_feature(self.project.args['app_id'], self.project.feature_summary, self.convo_feature_plan.messages)
if not self.project.skip_steps:
save_feature(self.project.args['app_id'],
self.project.feature_summary,
self.convo_feature_plan.messages,
self.project.checkpoints['last_development_step'])
logger.info('Summary for new feature is created.')
return

Loading…
Cancel
Save