From 1aec48a1357a143ac17889bb783f78385e1d054c Mon Sep 17 00:00:00 2001 From: Goran Peretin Date: Wed, 19 Jun 2024 07:27:36 +0000 Subject: [PATCH] Review fixes. Use JSON schema for LLM response. --- core/agents/troubleshooter.py | 6 +++++- .../troubleshooter/define_user_review_goal.prompt | 1 + core/prompts/troubleshooter/get_route_files.prompt | 12 ------------ 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/core/agents/troubleshooter.py b/core/agents/troubleshooter.py index ac00bcb54..271f343bf 100644 --- a/core/agents/troubleshooter.py +++ b/core/agents/troubleshooter.py @@ -159,7 +159,11 @@ async def _get_route_files(self) -> list[File]: """Returns the list of file paths that have routes defined in them.""" llm = self.get_llm(ROUTE_FILES_AGENT_NAME) - convo = self._get_task_convo().template("get_route_files", task=self.current_state.current_task) + convo = ( + self._get_task_convo() + .template("get_route_files", task=self.current_state.current_task) + .require_schema(RouteFilePaths) + ) file_list = await llm(convo, parser=JSONParser(RouteFilePaths)) route_files: set[str] = set(file_list.files) diff --git a/core/prompts/troubleshooter/define_user_review_goal.prompt b/core/prompts/troubleshooter/define_user_review_goal.prompt index 64299e41b..733dd5e86 100644 --- a/core/prompts/troubleshooter/define_user_review_goal.prompt +++ b/core/prompts/troubleshooter/define_user_review_goal.prompt @@ -8,6 +8,7 @@ File **`{{ file.path }}`** ({{file.content.content.splitlines()|length}} lines o {{ file.content.content }}``` {% endfor %} +---END_OF_FILES--- {% endif %} How can a human user test if this task was completed successfully? diff --git a/core/prompts/troubleshooter/get_route_files.prompt b/core/prompts/troubleshooter/get_route_files.prompt index 0cf2b3675..9edb6d1ce 100644 --- a/core/prompts/troubleshooter/get_route_files.prompt +++ b/core/prompts/troubleshooter/get_route_files.prompt @@ -8,15 +8,3 @@ them, and this prompt selects those files. #} Your task is to identify all the files, from the above list, that have routes defined in them. Return just the file paths as a JSON list named "files", DO NOT return anything else. If there are no files with routes, return an empty list. - -Example response: -``` -{ - "files": [ - "dir/file1.js", - "dir/file2.js", - ] -} -``` - -Your response must be a valid JSON format.