From 6cb356363314b62c634bf9b3bbe453ac8d63602d Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Fri, 8 Sep 2023 03:02:27 +1000 Subject: [PATCH 01/19] ignore pilot-env --- .gitignore | 341 +++++++++++++++++++++++++++-------------------------- 1 file changed, 171 insertions(+), 170 deletions(-) diff --git a/.gitignore b/.gitignore index d459a5fe8..104597d01 100644 --- a/.gitignore +++ b/.gitignore @@ -1,170 +1,171 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/#use-with-ide -.pdm.toml - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -.idea/ - - -# Logger -/pilot/logger/debug.log - -#sqlite -/pilot/gpt-pilot - -# workspace -workspace \ No newline at end of file +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +.idea/ + + +# Logger +/pilot/logger/debug.log + +#sqlite +/pilot/gpt-pilot + +# workspace +workspace +pilot-env/ From d81f387dc10e8aa7b72d88a82f21582054ae6de0 Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Fri, 8 Sep 2023 03:02:55 +1000 Subject: [PATCH 02/19] fixed typo in prompt --- pilot/prompts/dev_ops/debug.prompt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pilot/prompts/dev_ops/debug.prompt b/pilot/prompts/dev_ops/debug.prompt index 30de7cf95..bd0ddf9ca 100644 --- a/pilot/prompts/dev_ops/debug.prompt +++ b/pilot/prompts/dev_ops/debug.prompt @@ -7,7 +7,7 @@ You wanted me to check this - `{{ issue_description }}` but there was a problem{ `run_command` function will run a command on the machine and will return the CLI output to you so you can see what to do next. -`implement_code_changes` function will change the code where you just need to thoroughly describe what needs to be implmemented, I will implement the requested changes and let you know. +`implement_code_changes` function will change the code where you just need to thoroughly describe what needs to be implemented, I will implement the requested changes and let you know. Return a list of steps that are needed to debug this issue. By the time we execute the last step, the issue should be fixed completely. Also, make sure that at least the last step has `check_if_fixed` set to TRUE. From 69eeae5606c118254c6c4827217c8d5d817ea99f Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Fri, 8 Sep 2023 03:03:38 +1000 Subject: [PATCH 03/19] attempt to get email from ~/.gitconfig --- pilot/utils/arguments.py | 26 +++++++++++++++++++++++--- pilot/utils/test_arguments.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 pilot/utils/test_arguments.py diff --git a/pilot/utils/arguments.py b/pilot/utils/arguments.py index 859037361..b1f9b92c3 100644 --- a/pilot/utils/arguments.py +++ b/pilot/utils/arguments.py @@ -1,3 +1,5 @@ +import os +import re import sys import uuid @@ -39,9 +41,7 @@ def get_arguments(): arguments['user_id'] = str(uuid.uuid4()) if 'email' not in arguments: - # todo change email so its not uuid4 but make sure to fix storing of development steps where - # 1 user can have multiple apps. In that case each app should have its own development steps - arguments['email'] = str(uuid.uuid4()) + arguments['email'] = get_email() if 'password' not in arguments: arguments['password'] = 'password' @@ -54,3 +54,23 @@ def get_arguments(): print(colored(f'python main.py app_id={arguments["app_id"]}', 'green', attrs=['bold'])) print(colored('--------------------------------------------------------------\n', 'green', attrs=['bold'])) return arguments + + +def get_email(): + # Attempt to get email from .gitconfig + gitconfig_path = os.path.expanduser('~/.gitconfig') + + if os.path.exists(gitconfig_path): + with open(gitconfig_path, 'r') as file: + content = file.read() + + # Use regex to search for email address + email_match = re.search(r'email\s*=\s*([\w\.-]+@[\w\.-]+)', content) + + if email_match: + return email_match.group(1) + + # If not found, return a UUID + # todo change email so its not uuid4 but make sure to fix storing of development steps where + # 1 user can have multiple apps. In that case each app should have its own development steps + return str(uuid.uuid4()) diff --git a/pilot/utils/test_arguments.py b/pilot/utils/test_arguments.py new file mode 100644 index 000000000..3992826a3 --- /dev/null +++ b/pilot/utils/test_arguments.py @@ -0,0 +1,34 @@ +import pytest +from unittest.mock import patch, mock_open +import uuid +from .arguments import get_email + + +def test_email_found_in_gitconfig(): + mock_file_content = """ + [user] + name = test_user + email = test@example.com + """ + with patch('builtins.open', mock_open(read_data=mock_file_content)): + assert get_email() == "test@example.com" + + +def test_email_not_found_in_gitconfig(): + mock_file_content = """ + [user] + name = test_user + """ + mock_uuid = "12345678-1234-5678-1234-567812345678" + + with patch('builtins.open', mock_open(read_data=mock_file_content)): + with patch.object(uuid, "uuid4", return_value=mock_uuid): + assert get_email() == mock_uuid + + +def test_gitconfig_not_present(): + mock_uuid = "12345678-1234-5678-1234-567812345678" + + with patch('os.path.exists', return_value=False): + with patch.object(uuid, "uuid4", return_value=mock_uuid): + assert get_email() == mock_uuid From 3423f0683e1176631627687bf7e0a0d029b9a844 Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Fri, 8 Sep 2023 03:04:50 +1000 Subject: [PATCH 04/19] default MAX_GPT_MODEL_TOKENS to 8192. tests failed to run because could not parse missing env var MAX_TOKENS --- pilot/const/llm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pilot/const/llm.py b/pilot/const/llm.py index 8ae8ab85a..f1f2d6f0d 100644 --- a/pilot/const/llm.py +++ b/pilot/const/llm.py @@ -1,5 +1,5 @@ import os -MAX_GPT_MODEL_TOKENS = int(os.getenv('MAX_TOKENS')) +MAX_GPT_MODEL_TOKENS = int(os.getenv('MAX_TOKENS', 8192)) MIN_TOKENS_FOR_GPT_RESPONSE = 600 MAX_QUESTIONS = 5 END_RESPONSE = "EVERYTHING_CLEAR" \ No newline at end of file From 48edfae03c5ce4d612070d1d979b7b3e03675605 Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Fri, 8 Sep 2023 03:05:26 +1000 Subject: [PATCH 05/19] handle rate_limit_exceeded error --- pilot/utils/llm_connection.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pilot/utils/llm_connection.py b/pilot/utils/llm_connection.py index d72515e29..97b9e2356 100644 --- a/pilot/utils/llm_connection.py +++ b/pilot/utils/llm_connection.py @@ -1,6 +1,8 @@ +import re import requests import os import sys +import time import json import tiktoken import questionary @@ -147,6 +149,13 @@ def wrapper(*args, **kwargs): # If the specific error "context_length_exceeded" is present, simply return without retry if "context_length_exceeded" in err_str: raise Exception("context_length_exceeded") + if "rate_limit_exceeded" in err_str: + # Extracting the duration from the error string + match = re.search(r"Please try again in (\d+)ms.", err_str) + if match: + wait_duration = int(match.group(1)) / 1000 + time.sleep(wait_duration) + continue print(colored(f'There was a problem with request to openai API:', 'red')) print(err_str) @@ -187,10 +196,16 @@ def return_result(result_data, lines_printed): if endpoint == 'AZURE': # If yes, get the AZURE_ENDPOINT from .ENV file endpoint_url = os.getenv('AZURE_ENDPOINT') + '/openai/deployments/' + model + '/chat/completions?api-version=2023-05-15' - headers = {'Content-Type': 'application/json', 'api-key': os.getenv('AZURE_API_KEY')} + headers = { + 'Content-Type': 'application/json', + 'api-key': os.getenv('AZURE_API_KEY') + } else: # If not, send the request to the OpenAI endpoint - headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer ' + os.getenv("OPENAI_API_KEY")} + headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer ' + os.getenv("OPENAI_API_KEY") + } endpoint_url = 'https://api.openai.com/v1/chat/completions' response = requests.post( From cf94fcaebe02c6a489ceff636a6e6c80031931cd Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Fri, 8 Sep 2023 03:05:53 +1000 Subject: [PATCH 06/19] reordered imports --- pilot/database/database.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pilot/database/database.py b/pilot/database/database.py index 52d97114c..598022763 100644 --- a/pilot/database/database.py +++ b/pilot/database/database.py @@ -4,10 +4,10 @@ from functools import reduce import operator import psycopg2 -from const.common import PROMPT_DATA_TO_IGNORE -from logger.logger import logger from psycopg2.extensions import quote_ident +from const.common import PROMPT_DATA_TO_IGNORE +from logger.logger import logger from utils.utils import hash_data from database.config import DB_NAME, DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DATABASE_TYPE from database.models.components.base_models import database From c4af2750ac78b354a9c5d031d7bb259087ce24e0 Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Fri, 8 Sep 2023 03:56:17 +1000 Subject: [PATCH 07/19] user_id defaults to OS username --- pilot/utils/arguments.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pilot/utils/arguments.py b/pilot/utils/arguments.py index b1f9b92c3..de334e491 100644 --- a/pilot/utils/arguments.py +++ b/pilot/utils/arguments.py @@ -1,3 +1,4 @@ +import getpass import os import re import sys @@ -38,7 +39,7 @@ def get_arguments(): arguments['app_id'] = str(uuid.uuid4()) if 'user_id' not in arguments: - arguments['user_id'] = str(uuid.uuid4()) + arguments['user_id'] = getpass.getuser() if 'email' not in arguments: arguments['email'] = get_email() From 8cec113df934ff3d2a9847abecd5681b4d31e4ec Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Sat, 9 Sep 2023 10:46:03 +1000 Subject: [PATCH 08/19] test_username_to_uuid() --- pilot/utils/test_arguments.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pilot/utils/test_arguments.py b/pilot/utils/test_arguments.py index 3992826a3..f1844fc08 100644 --- a/pilot/utils/test_arguments.py +++ b/pilot/utils/test_arguments.py @@ -1,7 +1,7 @@ import pytest from unittest.mock import patch, mock_open import uuid -from .arguments import get_email +from .arguments import get_email, username_to_uuid def test_email_found_in_gitconfig(): @@ -32,3 +32,7 @@ def test_gitconfig_not_present(): with patch('os.path.exists', return_value=False): with patch.object(uuid, "uuid4", return_value=mock_uuid): assert get_email() == mock_uuid + + +def test_username_to_uuid(): + assert username_to_uuid("test_user") == "31676025-316f-b555-e0bf-a12f0bcfd0ea" From f50eda55842fdbc2d521b16f762ef017ce5cd01f Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Sat, 9 Sep 2023 11:06:17 +1000 Subject: [PATCH 09/19] quoted python version to avoid 3.10 being treated as 3.1 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e7e0f3d1..335731f17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.7, 3.8, 3.9, 3.10, 3.11] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] steps: - uses: actions/checkout@v2 From 310220b71989328ef90029871f011f0295a32079 Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Sat, 9 Sep 2023 11:12:41 +1000 Subject: [PATCH 10/19] python-dotenv does dropped support for python 3.7 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 335731f17..f051b890b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11'] steps: - uses: actions/checkout@v2 From 46b84315ecff04e8eb457bc0ac1a10a95bb1b363 Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Sat, 9 Sep 2023 11:16:11 +1000 Subject: [PATCH 11/19] get_step_code_changes() is undefined, commented out for now --- pilot/helpers/agents/Developer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pilot/helpers/agents/Developer.py b/pilot/helpers/agents/Developer.py index 47e41756e..9ff9e607f 100644 --- a/pilot/helpers/agents/Developer.py +++ b/pilot/helpers/agents/Developer.py @@ -259,7 +259,7 @@ def implement_step(self, convo, step_index, type, description): if type == 'COMMAND': for cmd in step_details: run_command_until_success(cmd['command'], cmd['timeout'], convo) - elif type == 'CODE_CHANGE': - code_changes_details = get_step_code_changes() + # elif type == 'CODE_CHANGE': + # code_changes_details = get_step_code_changes() # TODO: give to code monkey for implementation pass From c813d81d41057cbcefda37dff9400283c83b145f Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Sat, 9 Sep 2023 11:43:38 +1000 Subject: [PATCH 12/19] tests should pass in CI --- .github/workflows/ci.yml | 5 +++-- pilot/logger/__init__.py | 0 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 pilot/logger/__init__.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f051b890b..6c47fd998 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,11 +33,12 @@ jobs: pip install flake8 flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # stop the build if there are Python syntax errors or undefined names - #ruff --format=github --select=E9,F63,F7,F82 --target-version=py37 . + ruff --format=github --select=E9,F63,F7,F82 --target-version=py37 . # default set of ruff rules with GitHub Annotations #ruff --format=github --target-version=py37 . - name: Run tests run: | pip install pytest - pytest + cd pilot + PYTHONPATH=. pytest diff --git a/pilot/logger/__init__.py b/pilot/logger/__init__.py new file mode 100644 index 000000000..e69de29bb From 3f36d04821d67545f7d10c8bab86aebba3fabef3 Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Sat, 9 Sep 2023 11:44:19 +1000 Subject: [PATCH 13/19] resolved deprecation warning --- pilot/database/models/architecture.py | 2 +- pilot/database/models/command_runs.py | 2 +- pilot/database/models/development.py | 2 +- pilot/database/models/development_planning.py | 2 +- pilot/database/models/development_steps.py | 2 +- pilot/database/models/environment_setup.py | 2 +- pilot/database/models/file_snapshot.py | 2 +- pilot/database/models/project_description.py | 2 +- pilot/database/models/user_apps.py | 2 +- pilot/database/models/user_inputs.py | 2 +- pilot/database/models/user_stories.py | 2 +- pilot/database/models/user_tasks.py | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pilot/database/models/architecture.py b/pilot/database/models/architecture.py index 261acb907..e80613079 100644 --- a/pilot/database/models/architecture.py +++ b/pilot/database/models/architecture.py @@ -12,4 +12,4 @@ class Architecture(ProgressStep): architecture = JSONField() # Custom JSON field for SQLite class Meta: - db_table = 'architecture' + table_name = 'architecture' diff --git a/pilot/database/models/command_runs.py b/pilot/database/models/command_runs.py index b6c34c494..a6b55fbce 100644 --- a/pilot/database/models/command_runs.py +++ b/pilot/database/models/command_runs.py @@ -13,7 +13,7 @@ class CommandRuns(BaseModel): previous_step = ForeignKeyField('self', null=True, column_name='previous_step') class Meta: - db_table = 'command_runs' + table_name = 'command_runs' indexes = ( (('app', 'hash_id'), True), ) \ No newline at end of file diff --git a/pilot/database/models/development.py b/pilot/database/models/development.py index dea5a7e63..2d3faaa60 100644 --- a/pilot/database/models/development.py +++ b/pilot/database/models/development.py @@ -5,4 +5,4 @@ class Development(ProgressStep): class Meta: - db_table = 'development' + table_name = 'development' diff --git a/pilot/database/models/development_planning.py b/pilot/database/models/development_planning.py index 8fe7a5595..c5831a994 100644 --- a/pilot/database/models/development_planning.py +++ b/pilot/database/models/development_planning.py @@ -12,4 +12,4 @@ class DevelopmentPlanning(ProgressStep): development_plan = JSONField() # Custom JSON field for SQLite class Meta: - db_table = 'development_planning' + table_name = 'development_planning' diff --git a/pilot/database/models/development_steps.py b/pilot/database/models/development_steps.py index 6492a4de9..aaf6b663e 100644 --- a/pilot/database/models/development_steps.py +++ b/pilot/database/models/development_steps.py @@ -20,7 +20,7 @@ class DevelopmentSteps(BaseModel): previous_step = ForeignKeyField('self', null=True, column_name='previous_step') class Meta: - db_table = 'development_steps' + table_name = 'development_steps' indexes = ( (('app', 'hash_id'), True), ) diff --git a/pilot/database/models/environment_setup.py b/pilot/database/models/environment_setup.py index e34d60901..1fe22b706 100644 --- a/pilot/database/models/environment_setup.py +++ b/pilot/database/models/environment_setup.py @@ -3,4 +3,4 @@ class EnvironmentSetup(ProgressStep): class Meta: - db_table = 'environment_setup' + table_name = 'environment_setup' diff --git a/pilot/database/models/file_snapshot.py b/pilot/database/models/file_snapshot.py index 9138a5ff4..68659f240 100644 --- a/pilot/database/models/file_snapshot.py +++ b/pilot/database/models/file_snapshot.py @@ -12,7 +12,7 @@ class FileSnapshot(BaseModel): content = TextField() class Meta: - db_table = 'file_snapshot' + table_name = 'file_snapshot' indexes = ( (('development_step', 'file'), True), ) \ No newline at end of file diff --git a/pilot/database/models/project_description.py b/pilot/database/models/project_description.py index 462c1a266..bb4b5ac20 100644 --- a/pilot/database/models/project_description.py +++ b/pilot/database/models/project_description.py @@ -7,4 +7,4 @@ class ProjectDescription(ProgressStep): summary = TextField() class Meta: - db_table = 'project_description' + table_name = 'project_description' diff --git a/pilot/database/models/user_apps.py b/pilot/database/models/user_apps.py index d70672f16..38aee23dd 100644 --- a/pilot/database/models/user_apps.py +++ b/pilot/database/models/user_apps.py @@ -12,7 +12,7 @@ class UserApps(BaseModel): workspace = CharField(null=True) class Meta: - db_table = 'user_apps' + table_name = 'user_apps' indexes = ( (('app', 'user'), True), ) diff --git a/pilot/database/models/user_inputs.py b/pilot/database/models/user_inputs.py index 7d2451c01..8c8399376 100644 --- a/pilot/database/models/user_inputs.py +++ b/pilot/database/models/user_inputs.py @@ -13,7 +13,7 @@ class UserInputs(BaseModel): previous_step = ForeignKeyField('self', null=True, column_name='previous_step') class Meta: - db_table = 'user_inputs' + table_name = 'user_inputs' indexes = ( (('app', 'hash_id'), True), ) \ No newline at end of file diff --git a/pilot/database/models/user_stories.py b/pilot/database/models/user_stories.py index 025e2555d..dd7e06a4e 100644 --- a/pilot/database/models/user_stories.py +++ b/pilot/database/models/user_stories.py @@ -11,4 +11,4 @@ class UserStories(ProgressStep): else: user_stories = JSONField() # Custom JSON field for SQLite class Meta: - db_table = 'user_stories' + table_name = 'user_stories' diff --git a/pilot/database/models/user_tasks.py b/pilot/database/models/user_tasks.py index 533340a4d..261de2d9f 100644 --- a/pilot/database/models/user_tasks.py +++ b/pilot/database/models/user_tasks.py @@ -12,4 +12,4 @@ class UserTasks(ProgressStep): user_tasks = JSONField() # Custom JSON field for SQLite class Meta: - db_table = 'user_tasks' + table_name = 'user_tasks' From 4b64631bec3f1c1281c734dc961378e1eeff14e3 Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Sat, 9 Sep 2023 11:50:55 +1000 Subject: [PATCH 14/19] linting --- .github/workflows/ci.yml | 2 +- pilot/utils/llm_connection.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6c47fd998..d04d6dd5c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: # stop the build if there are Python syntax errors or undefined names ruff --format=github --select=E9,F63,F7,F82 --target-version=py37 . # default set of ruff rules with GitHub Annotations - #ruff --format=github --target-version=py37 . + #ruff --format=github --target-version=py37 --ignore=F401,E501 . - name: Run tests run: | diff --git a/pilot/utils/llm_connection.py b/pilot/utils/llm_connection.py index 97b9e2356..7a0b55caf 100644 --- a/pilot/utils/llm_connection.py +++ b/pilot/utils/llm_connection.py @@ -245,7 +245,7 @@ def return_result(result_data, lines_printed): if json_line['choices'][0]['finish_reason'] == 'function_call': function_calls['arguments'] = load_data_to_json(function_calls['arguments']) - return return_result({'function_calls': function_calls}, lines_printed); + return return_result({'function_calls': function_calls}, lines_printed) json_line = json_line['choices'][0]['delta'] From a38c7c4f6d7da03fec8ec5203fcc95a82d0d1779 Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Sat, 9 Sep 2023 11:54:16 +1000 Subject: [PATCH 15/19] linting --- pilot/main.py | 6 ++---- pilot/utils/arguments.py | 2 +- pilot/utils/llm_connection.py | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/pilot/main.py b/pilot/main.py index 751ea9aa6..8f4ab7c34 100644 --- a/pilot/main.py +++ b/pilot/main.py @@ -2,18 +2,16 @@ from __future__ import print_function, unicode_literals import sys - from dotenv import load_dotenv from termcolor import colored -load_dotenv() - from helpers.Project import Project - from utils.arguments import get_arguments from utils.exit import exit_gpt_pilot from logger.logger import logger from database.database import database_exists, create_database, tables_exist, create_tables +load_dotenv() + def init(): # Check if the "euclid" database exists, if not, create it diff --git a/pilot/utils/arguments.py b/pilot/utils/arguments.py index cc7104c14..e4409ebd5 100644 --- a/pilot/utils/arguments.py +++ b/pilot/utils/arguments.py @@ -53,7 +53,7 @@ def get_arguments(): else: arguments['app_id'] = str(uuid.uuid4()) print(colored('\n------------------ STARTING NEW PROJECT ----------------------', 'green', attrs=['bold'])) - print(f"If you wish to continue with this project in future run:") + print("If you wish to continue with this project in future run:") print(colored(f'python {sys.argv[0]} app_id={arguments["app_id"]}', 'green', attrs=['bold'])) print(colored('--------------------------------------------------------------\n', 'green', attrs=['bold'])) diff --git a/pilot/utils/llm_connection.py b/pilot/utils/llm_connection.py index 7a0b55caf..72167f289 100644 --- a/pilot/utils/llm_connection.py +++ b/pilot/utils/llm_connection.py @@ -118,7 +118,7 @@ def create_gpt_chat_completion(messages: List[dict], req_type, min_tokens=MIN_TO # Check if the error message is related to token limit if "context_length_exceeded" in error_message.lower(): - raise Exception(f'Too many tokens in the request. Please try to continue the project with some previous development step.') + raise Exception('Too many tokens in the request. Please try to continue the project with some previous development step.') else: print('The request to OpenAI API failed. Here is the error message:') print(e) @@ -157,7 +157,7 @@ def wrapper(*args, **kwargs): time.sleep(wait_duration) continue - print(colored(f'There was a problem with request to openai API:', 'red')) + print(colored('There was a problem with request to openai API:', 'red')) print(err_str) user_message = questionary.text( From 0a4d13e65caafde31096eb975edd770a4e8d8b25 Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Sat, 9 Sep 2023 11:56:05 +1000 Subject: [PATCH 16/19] install ruff --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d04d6dd5c..119b17c3d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: - name: Lint run: | - pip install flake8 + pip install flake8 ruff flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # stop the build if there are Python syntax errors or undefined names ruff --format=github --select=E9,F63,F7,F82 --target-version=py37 . From f2187b5a04a2133ad6bac15e3abf15ca746322fd Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Sat, 9 Sep 2023 12:02:22 +1000 Subject: [PATCH 17/19] fixed tests for CI --- pilot/utils/test_arguments.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pilot/utils/test_arguments.py b/pilot/utils/test_arguments.py index f1844fc08..25998e3aa 100644 --- a/pilot/utils/test_arguments.py +++ b/pilot/utils/test_arguments.py @@ -10,8 +10,9 @@ def test_email_found_in_gitconfig(): name = test_user email = test@example.com """ - with patch('builtins.open', mock_open(read_data=mock_file_content)): - assert get_email() == "test@example.com" + with patch('os.path.exists', return_value=True): + with patch('builtins.open', mock_open(read_data=mock_file_content)): + assert get_email() == "test@example.com" def test_email_not_found_in_gitconfig(): @@ -21,9 +22,10 @@ def test_email_not_found_in_gitconfig(): """ mock_uuid = "12345678-1234-5678-1234-567812345678" - with patch('builtins.open', mock_open(read_data=mock_file_content)): - with patch.object(uuid, "uuid4", return_value=mock_uuid): - assert get_email() == mock_uuid + with patch('os.path.exists', return_value=True): + with patch('builtins.open', mock_open(read_data=mock_file_content)): + with patch.object(uuid, "uuid4", return_value=mock_uuid): + assert get_email() == mock_uuid def test_gitconfig_not_present(): From 026eb69f2c3b071a28b6fda18f4fd2dcfb6a101d Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Sat, 9 Sep 2023 12:05:21 +1000 Subject: [PATCH 18/19] actions/checkout@v4 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 119b17c3d..c22a4400a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: python-version: ['3.8', '3.9', '3.10', '3.11'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 From b780a9f19cfef2f9d37aa0fb2eb377a378f85984 Mon Sep 17 00:00:00 2001 From: LeonOstrez <41999013+LeonOstrez@users.noreply.github.com> Date: Sat, 9 Sep 2023 09:53:48 +0200 Subject: [PATCH 19/19] load environment asap so that other files have it available --- pilot/main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pilot/main.py b/pilot/main.py index 8f4ab7c34..d4f9a8484 100644 --- a/pilot/main.py +++ b/pilot/main.py @@ -3,6 +3,7 @@ import sys from dotenv import load_dotenv +load_dotenv() from termcolor import colored from helpers.Project import Project from utils.arguments import get_arguments @@ -10,8 +11,6 @@ from logger.logger import logger from database.database import database_exists, create_database, tables_exist, create_tables -load_dotenv() - def init(): # Check if the "euclid" database exists, if not, create it