experimenting with ReAct prompting in debugger.

may remove `criticism`
pull/1160/head
Nicholas Albion 3 years ago
parent 1675c6651c
commit da52945ba6

@ -529,8 +529,19 @@ DEBUG_STEPS_BREAKDOWN = {
'description': 'Starts the debugging process based on the list of steps that need to be done to debug the problem.',
'parameters': {
'type': 'object',
"properties": {
"steps": {
'properties': {
'thoughts': {
'type': 'string',
'description': 'Thoughts that you have about the problem that you are trying to debug.'
},
'reasoning': {
'type': 'string',
},
'criticism': {
'type': 'string',
'description': 'Constructive self-criticism',
},
'steps': {
'type': 'array',
'description': 'List of steps that need to be done to debug the problem.',
'items': {
@ -560,7 +571,7 @@ DEBUG_STEPS_BREAKDOWN = {
}
}
},
"required": ['steps'],
"required": ['thoughts', 'reasoning', 'criticism', 'steps'],
},
},
],

@ -11,6 +11,7 @@ from utils.utils import array_of_objects_to_string, get_prompt, get_sys_message,
from logger.logger import logger
from prompts.prompts import ask_user
from const.llm import END_RESPONSE
from helpers.cli import running_processes
class AgentConvo:
@ -197,6 +198,18 @@ class AgentConvo:
print(f"\n{content}\n", type='local')
logger.info(f"{print_msg}: {content}\n")
def to_context_prompt(self):
logger.info(f'to_context_prompt({self.agent.project.current_step})')
# TODO: get dependencies & versions from the project (package.json, requirements.txt, pom.xml, etc.)
# Ideally, the LLM could do this, and we update it on load & whenever the file changes
# ...or LLM generates a script for `.gpt-pilot/get_dependencies` that we run
# https://github.com/Pythagora-io/gpt-pilot/issues/189
return get_prompt('development/context.prompt', {
'directory_tree': self.agent.project.get_directory_tree(),
'running_processes': running_processes,
})
def to_playground(self):
with open('const/convert_to_playground_convo.js', 'r', encoding='utf-8') as file:
content = file.read()

@ -5,6 +5,7 @@ from const.code_execution import MAX_COMMAND_DEBUG_TRIES, MAX_RECUSION_LAYER
from const.function_calls import DEBUG_STEPS_BREAKDOWN
from helpers.exceptions.TokenLimitError import TokenLimitError
from helpers.exceptions.TooDeepRecursionError import TooDeepRecursionError
from logger.logger import logger
class Debugger:
@ -41,15 +42,20 @@ class Debugger:
convo.load_branch(function_uuid)
debugging_plan = convo.send_message('dev_ops/debug.prompt',
thoughts, reasoning, criticism, debugging_plan = convo.send_message('dev_ops/debug.prompt',
{
'command': command['command'] if command is not None else None,
'user_input': user_input,
'issue_description': issue_description,
'os': platform.system()
'os': platform.system(),
'context': convo.to_context_prompt()
},
DEBUG_STEPS_BREAKDOWN)
logger.info(f'Thoughts: {thoughts}')
logger.info(f'Reasoning: {reasoning}')
logger.info(f'Criticism: {criticism}')
try:
# TODO refactor to nicely get the developer agent
response = self.agent.project.developer.execute_task(

@ -142,7 +142,9 @@ class Developer(Agent):
continue
if response['user_input'] != 'continue':
return_value = self.debugger.debug(convo, user_input=response['user_input'], issue_description=step['human_intervention_description'])
return_value = self.debugger.debug(convo,
user_input=response['user_input'],
issue_description=step['human_intervention_description'])
return_value['user_input'] = response['user_input']
return return_value
else:

@ -0,0 +1,28 @@
from dotenv import load_dotenv
from helpers.agents.Developer import Developer
from helpers.AgentConvo import AgentConvo
from .test_Project import create_project
load_dotenv()
from database.database import database
# database.init()
# database.connect(reuse_if_open=True)
def test_send_message_saved_dev_step(monkeypatch):
# Given
# monkeypatch.setenv('ENDPOINT', endpoint)
project = create_project()
project.args['app_id'] = '6f5f0a31-3c70-4162-86ff-3fa938aca9b9'
project.checkpoints['last_development_step'] = 135
project.current_step = 'coding'
developer = Developer(project)
convo = AgentConvo(developer)
# When
response = convo.send_message('development/define_user_review_goal.prompt', {'os': 'Test'})
# Then
assert response is not None

@ -3,7 +3,9 @@ You wanted me to check this - `{{ issue_description }}` but there was a problem{
```
{{ user_input }}
```
{% endif %}I want you to debug this issue by yourself and I will give you 2 functions that you can use - `run_command` and `implement_code_changes`.
{% endif -%}
{{ context }}
I want you to debug this issue by yourself and I will give you 2 functions that you can use - `run_command` and `implement_code_changes`.
`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. Note that the command will run on a {{ os }} machine.

@ -0,0 +1,12 @@
{%- if directory_tree %}
The project directory tree looks like:
{{ directory_tree }}
{% endif -%}
{%- if running_processes %}
Note that the following processes are already running:
{% for key, data in running_processes.items() -%}
- "{{ key }}" (`{{ data[0] }}`)
{% endfor -%}
{% endif -%}
Loading…
Cancel
Save