From fd6254d1fd3355072659d42d4ae80eda84baf819 Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Fri, 6 Oct 2023 18:24:25 +1100 Subject: [PATCH] send exit code to LLM --- pilot/prompts/__init__.py | 0 pilot/prompts/dev_ops/ran_command.prompt | 10 +++--- pilot/prompts/test_prompts.py | 45 ++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 pilot/prompts/__init__.py create mode 100644 pilot/prompts/test_prompts.py diff --git a/pilot/prompts/__init__.py b/pilot/prompts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pilot/prompts/dev_ops/ran_command.prompt b/pilot/prompts/dev_ops/ran_command.prompt index a586686..5617503 100644 --- a/pilot/prompts/dev_ops/ran_command.prompt +++ b/pilot/prompts/dev_ops/ran_command.prompt @@ -1,8 +1,6 @@ {{ additional_info }}I ran the command `{{ command }}` -{%- if exit_code %}, the exit code was {{ exit_code }} {% endif -%} -and the output was: -``` -{{ cli_response }} -``` +{%- if exit_code is number %}, the exit code was {{ exit_code }}{% endif %} and the output was: -If the command was successfully executed, respond with `DONE` and if it wasn't, respond with `NEEDS_DEBUGGING`. +{{ cli_response }} + +If the command was successfully executed, respond with `DONE`. If it wasn't, respond with `NEEDS_DEBUGGING` and single line explanation. diff --git a/pilot/prompts/test_prompts.py b/pilot/prompts/test_prompts.py new file mode 100644 index 0000000..b71c03f --- /dev/null +++ b/pilot/prompts/test_prompts.py @@ -0,0 +1,45 @@ +from .prompts import get_prompt + + +def test_prompt_ran_command_None_exit(): + # When + prompt = get_prompt('dev_ops/ran_command.prompt', { + 'cli_response': 'stdout:\n```\nsuccess\n```', + 'command': './scripts/run_tests', + 'additional_message': 'Some additional message\n', + 'exit_code': None + }) + + # Then + assert prompt == ''' +I ran the command `./scripts/run_tests` and the output was: + +stdout: +``` +success +``` + +If the command was successfully executed, respond with `DONE`. If it wasn't, respond with `NEEDS_DEBUGGING` and single line explanation. +'''.strip() + + +def test_prompt_ran_command_0_exit(): + # When + prompt = get_prompt('dev_ops/ran_command.prompt', { + 'cli_response': 'stdout:\n```\nsuccess\n```', + 'command': './scripts/run_tests', + 'additional_message': 'Some additional message\n', + 'exit_code': 0 + }) + + # Then + assert prompt == ''' +I ran the command `./scripts/run_tests`, the exit code was 0 and the output was: + +stdout: +``` +success +``` + +If the command was successfully executed, respond with `DONE`. If it wasn't, respond with `NEEDS_DEBUGGING` and single line explanation. +'''.strip()