Skip to content

Commit

Permalink
fix: book prompts, example fully works again. close #4
Browse files Browse the repository at this point in the history
  • Loading branch information
samholt committed Dec 27, 2024
1 parent 2ad39de commit 541ec44
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion l2mac/prompts/book.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ control_unit_instruction_complete_summarize_output: |
control_unit_instruction_erroring_fix_the_code: |
{error_message}\n\nReflect and write the full complete corrected text to correct the text. Condition it on existing text: {file_names}.\n{test_writing_advice}\n\nRespond now only with a function call of one of the following functions provided: {functions_provided}, and if you want to output text only use the `write_files` function to output text.
control_unit_cycle_message_to_check_if_instruction_complete: |
Has the sub task step been completed of:```{step}```.\n\n If yes, call the function `sub_task_step_complete`, otherwise reflect and correct the full text to complete the task. Note: Condition any new text files on the existing text files: {file_names}. Fully implement these features in the text, no placeholders. {test_writing_advice}\n Respond now only with a function call of one of the following functions provided: {functions_provided}, and if you want to output text only use the `write_files` function to output text.
Has the sub task step been completed of:```{step}```.\n\n If yes, call the function `sub_task_step_complete`, otherwise reflect and correct the full text to complete the task. Note: Condition any new text files on the existing text files: {file_names}. Fully implement these features in the text, no placeholders. \n Respond now only with a function call of one of the following functions provided: {functions_provided}, and if you want to output text only use the `write_files` function to output text.
4 changes: 2 additions & 2 deletions l2mac/tools/code_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def check_pytest(file_dict: dict):

def pytest_files(files_to_test: List[str],
file_dict: dict,
enable_tests=True):
enable_tests=True) -> str:
if not enable_tests:
output = "Manual tests passed."
return json.dumps({"output": output})
Expand Down Expand Up @@ -212,7 +212,7 @@ def run_python_file(
file_dict: dict,
arguments: List[str],
enable_tests=True,
):
) -> str:
if not enable_tests:
output = "Manual tests passed."
return json.dumps({"output": output})
Expand Down
5 changes: 3 additions & 2 deletions l2mac/tools/control_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
)


def provide_detailed_sub_task_steps_for_sub_agents(steps: List[str]):
def provide_detailed_sub_task_steps_for_sub_agents(steps:
List[str]) -> List[str]:
return steps


def check_sub_task_step_complete(file_dict: dict, enable_tests=True):
def check_sub_task_step_complete(file_dict: dict, enable_tests=True) -> str:
# Run tests & Syntax checks
if not enable_tests:
output = {"status": "TASK_STEP_COMPLETE", "message": "All tests passed"}
Expand Down
7 changes: 4 additions & 3 deletions l2mac/tools/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"""
import json
import traceback
from typing import List
from typing import Any, List, Tuple

from l2mac.tools.code_analysis import pytest_files, run_python_file
from l2mac.tools.control_unit import (
Expand Down Expand Up @@ -226,7 +226,8 @@ def process_function_call_and_return_message(tool_calls: dict,
file_dict: dict,
tools: List[dict],
logger=None,
enable_tests=True):
enable_tests=True) -> \
Tuple[list[dict[str, Any]], dict]:
function_name = ""
if len(tools) >= 1:
functions_available_keys = process_functions_into_function_names(tools)
Expand Down Expand Up @@ -336,4 +337,4 @@ def process_function_call_and_return_message(tool_calls: dict,
"content": json_fun_content,
}
return_messages.append(function_return_message)
return return_messages, file_dict
return return_messages, file_dict # pytype: disable=bad-return-type
5 changes: 3 additions & 2 deletions l2mac/tools/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class for testing the formatting function.

def view_files(files: List[str],
file_dict: dict,
enable_tests=True): # pylint: disable=unused-argument
enable_tests=True) -> str: # pylint: disable=unused-argument
files_not_found = []
for f in files:
if f not in file_dict:
Expand Down Expand Up @@ -64,7 +64,8 @@ def view_files(files: List[str],
return json.dumps(response)


def list_files(folder_path: str, file_dict: dict, enable_tests=True): # pylint: disable=unused-argument
def list_files(folder_path: str, # pylint: disable=unused-argument
file_dict: dict, enable_tests=True) -> str: # pylint: disable=unused-argument
return json.dumps({"files": list(file_dict.keys())})


Expand Down
12 changes: 6 additions & 6 deletions l2mac/tools/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"""
import json
from copy import deepcopy
from typing import List
from typing import List, Tuple

from l2mac.tools.code_analysis import (
check_pytest_with_timeout,
Expand All @@ -73,7 +73,7 @@ def write_files(
list_of_file_objects: List[dict],
file_dict: dict,
enable_tests=True,
):
) -> Tuple[str, dict]:
new_file_dict = implement_git_diff_on_file_dict(
file_dict_input=file_dict,
change_files_and_contents_input=list_of_file_objects,
Expand Down Expand Up @@ -104,9 +104,6 @@ def write_files(
}
else:
new_output = test_results.strip() + "\n" + syntax_results.strip()
# if len(new_output) > 5000:
# new_output = new_output[:5000]
# new_output = new_output + '\nRest of output was trimmed.'
output = {
"write_files_status":
"success",
Expand Down Expand Up @@ -168,7 +165,10 @@ def update_file_contents(existing_file_contents,
return existing_file_contents.split("\n")


def delete_files(files: List[str], file_dict: dict, enable_tests=True): # pylint: disable=unused-argument
def delete_files(files: List[str],
file_dict: dict,
enable_tests=True) \
-> Tuple[str, dict]: # pylint: disable=unused-argument
for file in files:
if file == "-1":
file_dict = {}
Expand Down

0 comments on commit 541ec44

Please sign in to comment.