-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add route files content to prompt for user instructions.
- Loading branch information
Showing
5 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
core/prompts/troubleshooter/define_user_review_goal.prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{# eval-tool test ID: 74918173-59e4-4005-bf19-d28f3bc9f06c | ||
|
||
This was added in June 2024, to improve the accuracy of user testing instructions. | ||
We've noticed that the LLM would often times include incorrect URLs in the user testing | ||
instructions, because it wasn't aware of the routes used in the application. | ||
The solution was to add the entire content of all the files that have routes defined in | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import pytest | ||
|
||
from core.agents.troubleshooter import RouteFilePaths, Troubleshooter | ||
from core.db.models import File, FileContent | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_route_files_are_included_in_the_prompt(agentcontext): | ||
sm, _, ui, mock_get_llm = agentcontext | ||
|
||
sm.current_state.tasks = [{"description": "Some task", "status": "todo", "instructions": "Testing here!"}] | ||
files = [ | ||
File(path="dir/file1.js", content=FileContent(content="File 1 content")), | ||
File(path="dir/file2.js", content=FileContent(content="File 2 content")), | ||
] | ||
|
||
await sm.commit() | ||
sm.current_state.files = files | ||
|
||
ts = Troubleshooter(sm, ui) | ||
ts.get_llm = mock_get_llm( | ||
side_effect=[ | ||
RouteFilePaths(files=["dir/file1.js"]), # First LLM call, to select files with routes | ||
"", # Second LLM call, to generate the actual instructions | ||
] | ||
) | ||
await ts.get_user_instructions() | ||
second_llm_call = ts.get_llm().call_args_list[1] | ||
user_msg_contents = [msg["content"] for msg in second_llm_call[0][0] if msg["role"] == "user"] | ||
assert "File 1 content" in user_msg_contents[1] # Prompt at [1] has the route file contents | ||
assert "File 2 content" not in user_msg_contents[1] |