mirror of
https://github.com/Pythagora-io/gpt-pilot.git
synced 2026-01-09 13:17:55 -05:00
Merge branch 'main' into term_process
This commit is contained in:
13
.github/workflows/ci.yml
vendored
13
.github/workflows/ci.yml
vendored
@@ -21,20 +21,15 @@ jobs:
|
||||
run: docker ps
|
||||
- name: Stop the Docker image
|
||||
run: docker compose down
|
||||
|
||||
|
||||
Test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
# 3.10 - 04 Oct 2021
|
||||
# 3.11 - 24 Oct 2022
|
||||
python-version: ['3.9', '3.10', '3.11', '3.12']
|
||||
# Test latest and oldest supported Python releases
|
||||
# See https://devguide.python.org/versions/
|
||||
python-version: ['3.9', '3.12']
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
exclude:
|
||||
# LINK : fatal error LNK1181: cannot open input file 'libpq.lib'
|
||||
# Maybe related: https://github.com/psycopg/psycopg2/issues/1628
|
||||
- os: windows-latest
|
||||
python-version: '3.12'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -54,9 +54,10 @@ https://github.com/Pythagora-io/gpt-pilot/assets/10895136/0495631b-511e-451b-93d
|
||||
|
||||
# 🔌 Requirements
|
||||
|
||||
- **Python 3.9-3.11** (3.12 is currently not working due to a [dependency issue](https://github.com/psycopg/psycopg2/issues/1628)
|
||||
|
||||
- **Python 3.9-3.12**
|
||||
- **PostgreSQL** (optional, projects default is SQLite)
|
||||
- DB is needed for multiple reasons like continuing app development. If you have to stop at any point or the app crashes, go back to a specific step so that you can change some later steps in development, and easier debugging, in future we will add functionality to update project (change some things in existing project or add new features to the project and so on)...
|
||||
- DB is needed for multiple reasons like continuing app development. If you have to stop at any point or the app crashes, go back to a specific step so that you can change some later steps in development, and easier debugging, in future we will add functionality to update project (change some things in existing project or add new features to the project and so on..)
|
||||
|
||||
|
||||
# 🚦How to start using gpt-pilot?
|
||||
@@ -67,10 +68,10 @@ After you have Python and (optionally) PostgreSQL installed, follow these steps:
|
||||
4. `source pilot-env/bin/activate` (or on Windows `pilot-env\Scripts\activate`) (activate the virtual environment)
|
||||
5. `pip install -r requirements.txt` (install the dependencies)
|
||||
6. `cd pilot`
|
||||
7. `mv .env.example .env` (create the .env file)
|
||||
7. `mv .env.example .env` (or on Windows `copy .env.example .env`) (create the .env file)
|
||||
8. Add your environment to the `.env` file:
|
||||
- LLM Provider (OpenAI/Azure/Openrouter)
|
||||
- your API key
|
||||
- Your API key
|
||||
- database settings: SQLite/PostgreSQL (to change from SQLite to PostgreSQL, just set `DATABASE_TYPE=postgres`)
|
||||
- optionally set IGNORE_FOLDERS for the folders which shouldn't be tracked by GPT Pilot in workspace, useful to ignore folders created by compilers (i.e. `IGNORE_FOLDERS=folder1,folder2,folder3`)
|
||||
9. `python db_init.py` (initialize the database)
|
||||
|
||||
@@ -568,7 +568,7 @@ class Developer(Agent):
|
||||
|
||||
user_feedback = response['user_input']
|
||||
if user_feedback is not None and user_feedback != 'continue':
|
||||
self.debugger.debug(convo, user_input=user_feedback, issue_description=description)
|
||||
self.debugger.debug(convo, user_input=user_feedback, issue_description=description) # noqa
|
||||
# return_value = {'success': debug_success, 'user_input': user_feedback}
|
||||
else:
|
||||
return_value = {'success': True, 'user_input': user_feedback}
|
||||
|
||||
@@ -168,6 +168,7 @@ This step will not be executed. no, use a better command
|
||||
# Then
|
||||
assert result == {'success': True, 'user_input': 'continue'}
|
||||
|
||||
@pytest.mark.skip("endless loop in questionary")
|
||||
@patch('helpers.AgentConvo.get_saved_development_step')
|
||||
@patch('helpers.AgentConvo.save_development_step')
|
||||
@patch('helpers.AgentConvo.create_gpt_chat_completion')
|
||||
|
||||
@@ -1,20 +1,27 @@
|
||||
from unittest.mock import patch, MagicMock
|
||||
import platform
|
||||
from unittest.mock import patch, MagicMock, call
|
||||
|
||||
from helpers.cli import execute_command, terminate_process, run_command_until_success
|
||||
from helpers.test_Project import create_project
|
||||
|
||||
@patch("helpers.cli.os")
|
||||
@patch("helpers.cli.subprocess")
|
||||
def test_terminate_process_not_running(mock_subprocess, mock_os):
|
||||
terminate_process(1234, 'not running')
|
||||
if platform.system() == 'Windows':
|
||||
mock_subprocess.run.assert_called_once_with(["taskkill", "/F", "/T", "/PID", "1234"])
|
||||
else:
|
||||
mock_os.killpg.assert_called_once_with(1234, 9)
|
||||
|
||||
def test_terminate_process_not_running():
|
||||
terminate_process(999999999, 'not running')
|
||||
assert True
|
||||
|
||||
|
||||
@patch("helpers.cli.MIN_COMMAND_RUN_TIME", create=True, new=100)
|
||||
@patch('helpers.cli.get_saved_command_run')
|
||||
@patch('helpers.cli.run_command')
|
||||
def test_execute_command_timeout_exit_code(mock_run, mock_get_saved_command):
|
||||
@patch("helpers.cli.terminate_process")
|
||||
def test_execute_command_timeout_exit_code(mock_terminate_process, mock_run, mock_get_saved_command):
|
||||
# Given
|
||||
project = create_project()
|
||||
command = 'ping www.google.com'
|
||||
timeout = 1
|
||||
command = 'cat'
|
||||
timeout = 0.1
|
||||
mock_process = MagicMock()
|
||||
mock_process.poll.return_value = None
|
||||
mock_process.pid = 1234
|
||||
@@ -25,21 +32,27 @@ def test_execute_command_timeout_exit_code(mock_run, mock_get_saved_command):
|
||||
|
||||
# Then
|
||||
assert cli_response is not None
|
||||
assert llm_response == 'took longer than 2000ms so I killed it'
|
||||
assert llm_response == 'took longer than 100.0ms so I killed it'
|
||||
assert exit_code is not None
|
||||
mock_terminate_process.assert_has_calls([
|
||||
call(1234),
|
||||
call(1234),
|
||||
])
|
||||
|
||||
|
||||
def mock_run_command(command, path, q, q_stderr):
|
||||
q.put('hello')
|
||||
mock_process = MagicMock()
|
||||
mock_process.returncode = 0
|
||||
mock_process.pid = 1234
|
||||
return mock_process
|
||||
|
||||
|
||||
@patch('helpers.cli.get_saved_command_run')
|
||||
@patch('helpers.cli.ask_user', return_value='')
|
||||
@patch('helpers.cli.run_command')
|
||||
def test_execute_command_enter(mock_run, mock_ask, mock_get_saved_command):
|
||||
@patch("helpers.cli.terminate_process")
|
||||
def test_execute_command_enter(mock_terminate_process, mock_run, mock_ask, mock_get_saved_command):
|
||||
# Given
|
||||
project = create_project()
|
||||
command = 'echo hello'
|
||||
@@ -53,12 +66,14 @@ def test_execute_command_enter(mock_run, mock_ask, mock_get_saved_command):
|
||||
assert 'hello' in cli_response
|
||||
assert llm_response is None
|
||||
assert exit_code == 0
|
||||
mock_terminate_process.assert_called_once_with(1234)
|
||||
|
||||
|
||||
@patch('helpers.cli.get_saved_command_run')
|
||||
@patch('helpers.cli.ask_user', return_value='yes')
|
||||
@patch('helpers.cli.run_command')
|
||||
def test_execute_command_yes(mock_run, mock_ask, mock_get_saved_command):
|
||||
@patch('helpers.cli.terminate_process')
|
||||
def test_execute_command_yes(mock_terminate_process, mock_run, mock_ask, mock_get_saved_command):
|
||||
# Given
|
||||
project = create_project()
|
||||
command = 'echo hello'
|
||||
@@ -72,6 +87,7 @@ def test_execute_command_yes(mock_run, mock_ask, mock_get_saved_command):
|
||||
assert 'hello' in cli_response
|
||||
assert llm_response is None
|
||||
assert exit_code == 0
|
||||
mock_terminate_process.assert_called_once_with(1234)
|
||||
|
||||
|
||||
@patch('helpers.cli.get_saved_command_run')
|
||||
|
||||
@@ -25,7 +25,7 @@ class DotGptPilot:
|
||||
def with_root_path(self, root_path: str, create=True):
|
||||
if not USE_GPTPILOT_FOLDER:
|
||||
return
|
||||
dot_gpt_pilot_path = os.path.join(root_path, '.gpt-pilot')
|
||||
dot_gpt_pilot_path = os.path.expanduser(os.path.join(root_path, '.gpt-pilot'))
|
||||
self.dot_gpt_pilot_path = dot_gpt_pilot_path
|
||||
|
||||
# Create the `.gpt-pilot` directory if required.
|
||||
|
||||
@@ -10,7 +10,7 @@ MarkupSafe==2.1.3
|
||||
peewee==3.16.2
|
||||
prompt-toolkit==3.0.39
|
||||
psutil==5.9.6
|
||||
psycopg2-binary==2.9.6
|
||||
psycopg2-binary==2.9.9
|
||||
python-dotenv==1.0.0
|
||||
python-editor==1.0.4
|
||||
pytest==7.4.2
|
||||
|
||||
Reference in New Issue
Block a user