mirror of
https://github.com/OMGeeky/gpt-pilot.git
synced 2026-01-01 00:50:01 +01:00
Merge pull request #111 from Pythagora-io/fix/handle-step_check.prompt
handle step check.prompt
This commit is contained in:
@@ -4,6 +4,7 @@ from utils.style import green_bold, yellow_bold, cyan, white_bold
|
||||
from const.common import IGNORE_FOLDERS, STEPS
|
||||
from database.database import delete_unconnected_steps_from, delete_all_app_development_data
|
||||
from const.ipc import MESSAGE_TYPE
|
||||
from prompts.prompts import ask_user
|
||||
from helpers.exceptions.TokenLimitError import TokenLimitError
|
||||
from utils.questionary import styled_text
|
||||
from helpers.files import get_files_content, clear_directory, update_file
|
||||
@@ -302,16 +303,14 @@ class Project:
|
||||
reset_branch_id = convo.save_branch()
|
||||
|
||||
while answer != 'continue':
|
||||
print(yellow_bold(message))
|
||||
if description is not None:
|
||||
print('\n' + '-'*100 + '\n' +
|
||||
white_bold(description) +
|
||||
'\n' + '-'*100 + '\n')
|
||||
|
||||
answer = styled_text(
|
||||
self,
|
||||
'If something is wrong, tell me or type "continue" to continue.',
|
||||
)
|
||||
answer = ask_user(self, yellow_bold(message),
|
||||
require_some_input=False,
|
||||
hint='If something is wrong, tell me or type "continue" to continue.')
|
||||
|
||||
try:
|
||||
if answer in cbs:
|
||||
|
||||
@@ -382,26 +382,23 @@ class Developer(Agent):
|
||||
return llm_response
|
||||
|
||||
def test_code_changes(self, code_monkey, convo):
|
||||
(test_type, command, automated_test_description, manual_test_description) = convo.send_message(
|
||||
'development/task/step_check.prompt',
|
||||
{},
|
||||
GET_TEST_TYPE)
|
||||
test_type, description = convo.send_message('development/task/step_check.prompt', {}, GET_TEST_TYPE)
|
||||
|
||||
if test_type == 'command_test':
|
||||
return run_command_until_success(command['command'], command['timeout'], convo)
|
||||
return run_command_until_success(description['command'], description['timeout'], convo)
|
||||
elif test_type == 'automated_test':
|
||||
# TODO get code monkey to implement the automated test
|
||||
pass
|
||||
elif test_type == 'manual_test':
|
||||
# TODO make the message better
|
||||
response = self.project.ask_for_human_intervention(
|
||||
'Message from Pilot: I need your help. Can you please test if this was successful?',
|
||||
manual_test_description
|
||||
'I need your help. Can you please test if this was successful?',
|
||||
description,
|
||||
)
|
||||
|
||||
user_feedback = response['user_input']
|
||||
if user_feedback is not None and user_feedback != 'continue':
|
||||
return_value = self.debugger.debug(convo, user_input=user_feedback, issue_description=manual_test_description)
|
||||
return_value = self.debugger.debug(convo, user_input=user_feedback, issue_description=description)
|
||||
return_value['user_input'] = user_feedback
|
||||
return return_value
|
||||
else:
|
||||
|
||||
@@ -51,3 +51,46 @@ class TestDeveloper:
|
||||
# Then
|
||||
assert llm_response == 'DONE'
|
||||
mock_execute_command.assert_called_once_with(self.project, 'python --version', 10)
|
||||
|
||||
@patch('helpers.AgentConvo.get_saved_development_step')
|
||||
@patch('helpers.AgentConvo.save_development_step')
|
||||
# GET_TEST_TYPE has optional properties, so we need to be able to handle missing args.
|
||||
@patch('helpers.AgentConvo.create_gpt_chat_completion',
|
||||
return_value={'text': '{"type": "command_test", "command": {"command": "npm run test", "timeout": 3000}}'})
|
||||
# 2nd arg of return_value: `None` to debug, 'DONE' if successful
|
||||
@patch('helpers.cli.execute_command', return_value=('stdout:\n```\n\n```', 'DONE'))
|
||||
# @patch('helpers.cli.ask_user', return_value='yes')
|
||||
# @patch('helpers.cli.get_saved_command_run')
|
||||
def test_code_changes_command_test(self, mock_get_saved_step, mock_save, mock_chat_completion,
|
||||
# Note: the 2nd line below will use the LLM to debug, uncomment the @patches accordingly
|
||||
mock_execute_command):
|
||||
# mock_ask_user, mock_get_saved_command_run):
|
||||
# Given
|
||||
monkey = None
|
||||
convo = AgentConvo(self.developer)
|
||||
convo.save_branch = lambda branch_name=None: branch_name
|
||||
|
||||
# When
|
||||
# "Now, we need to verify if this change was successfully implemented...
|
||||
result = self.developer.test_code_changes(monkey, convo)
|
||||
|
||||
# Then
|
||||
assert result == {'success': True, 'cli_response': 'stdout:\n```\n\n```'}
|
||||
|
||||
@patch('helpers.AgentConvo.get_saved_development_step')
|
||||
@patch('helpers.AgentConvo.save_development_step')
|
||||
# GET_TEST_TYPE has optional properties, so we need to be able to handle missing args.
|
||||
@patch('helpers.AgentConvo.create_gpt_chat_completion',
|
||||
return_value={'text': '{"type": "manual_test", "manual_test_description": "Does it look good?"}'})
|
||||
@patch('helpers.Project.ask_user', return_value='continue')
|
||||
def test_code_changes_manual_test(self, mock_get_saved_step, mock_save, mock_chat_completion, mock_ask_user):
|
||||
# Given
|
||||
monkey = None
|
||||
convo = AgentConvo(self.developer)
|
||||
convo.save_branch = lambda branch_name=None: branch_name
|
||||
|
||||
# When
|
||||
result = self.developer.test_code_changes(monkey, convo)
|
||||
|
||||
# Then
|
||||
assert result == {'success': True, 'user_input': 'continue'}
|
||||
|
||||
Reference in New Issue
Block a user