mirror of
https://github.com/OMGeeky/gpt-pilot.git
synced 2026-01-01 17:09:59 +01:00
Added File model
This commit is contained in:
@@ -19,6 +19,7 @@ from database.models.development import Development
|
||||
from database.models.file_snapshot import FileSnapshot
|
||||
from database.models.command_runs import CommandRuns
|
||||
from database.models.user_inputs import UserInputs
|
||||
from database.models.files import File
|
||||
|
||||
|
||||
def save_user(user_id, email, password):
|
||||
@@ -262,6 +263,7 @@ def create_tables():
|
||||
FileSnapshot,
|
||||
CommandRuns,
|
||||
UserInputs,
|
||||
File,
|
||||
])
|
||||
|
||||
|
||||
@@ -281,6 +283,7 @@ def drop_tables():
|
||||
FileSnapshot,
|
||||
CommandRuns,
|
||||
UserInputs,
|
||||
File,
|
||||
]:
|
||||
database.execute_sql(f'DROP TABLE IF EXISTS "{table._meta.table_name}" CASCADE')
|
||||
|
||||
|
||||
15
euclid/database/models/files.py
Normal file
15
euclid/database/models/files.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from peewee import *
|
||||
|
||||
from database.models.components.base_models import BaseModel
|
||||
from database.models.development_steps import DevelopmentSteps
|
||||
from database.models.app import App
|
||||
|
||||
class File(BaseModel):
|
||||
app = ForeignKeyField(App)
|
||||
name = CharField()
|
||||
description = TextField()
|
||||
|
||||
class Meta:
|
||||
indexes = (
|
||||
(('app', 'name'), True),
|
||||
)
|
||||
@@ -2,6 +2,8 @@ import os
|
||||
|
||||
from termcolor import colored
|
||||
from const.common import IGNORE_FOLDERS
|
||||
from database.models.app import App
|
||||
from database.database import get_app
|
||||
from utils.questionary import styled_text
|
||||
from helpers.files import get_files_content, clear_directory
|
||||
from helpers.cli import build_directory_tree
|
||||
@@ -29,6 +31,9 @@ class Project:
|
||||
self.root_path = ''
|
||||
# self.restore_files({dev_step_id_to_start_from})
|
||||
|
||||
if 'app_id' in args:
|
||||
self.app = get_app(args['app_id'])
|
||||
|
||||
if current_step is not None:
|
||||
self.current_step = current_step
|
||||
if name is not None:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from const.function_calls import GET_FILES, DEV_STEPS, IMPLEMENT_CHANGES, CODE_CHANGES
|
||||
from database.models.files import File
|
||||
from helpers.files import update_file
|
||||
from helpers.AgentConvo import AgentConvo
|
||||
from helpers.Agent import Agent
|
||||
@@ -27,6 +28,14 @@ class CodeMonkey(Agent):
|
||||
}, IMPLEMENT_CHANGES, True)
|
||||
|
||||
for file_data in changes:
|
||||
update_file(self.project.get_full_file_path(file_data['name']), file_data['content'])
|
||||
if file_data['description'] != '':
|
||||
(File.insert(app=self.project.app, name=file_data['path'], description=file_data['description'])
|
||||
.on_conflict(
|
||||
conflict_target=[File.app, File.name],
|
||||
preserve=[],
|
||||
update={'description': file_data['description']})
|
||||
.execute())
|
||||
|
||||
update_file(self.project.get_full_file_path(file_data['path']), file_data['content'])
|
||||
|
||||
return convo
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
from termcolor import colored
|
||||
import os
|
||||
|
||||
from database.models.development_steps import DevelopmentSteps
|
||||
from database.models.file_snapshot import FileSnapshot
|
||||
|
||||
|
||||
def update_file(path, new_content):
|
||||
# Ensure the directory exists; if not, create it
|
||||
|
||||
Reference in New Issue
Block a user