Open wwzeng1 opened 9 months ago
f85850415a
)Here are the sandbox execution logs prior to making any changes:
1bc1b31
Checking sweepai/utils/ticket_utils.py for syntax errors... ✅ sweepai/utils/ticket_utils.py has no syntax errors!
1/1 ✓Checking sweepai/utils/ticket_utils.py for syntax errors... ✅ sweepai/utils/ticket_utils.py has no syntax errors!
Sandbox passed on the latest main
, so sandbox checks will be enabled for this issue.
I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.
sweepai/agents/filter_agent.py
✓ https://github.com/sweepai/sweep/commit/da604ba2c876a82460d66c6672ccf8eb3c69c39e Edit
Create sweepai/agents/filter_agent.py with contents:
• Create a new file `filter_agent.py` in the `sweepai/agents/` directory.
• Import the necessary modules and classes. This will include `ChatGPT` from `openai` and `serialize_method_name` from `name_agent.py`.
• Define a new class `FilterBot` that inherits from `ChatGPT`.
• Inside the `FilterBot` class, define a prompt that will be used to filter out unnecessary terms from a given search query. The prompt should be designed in a way that it instructs the model to filter out unnecessary terms from the input.
• Implement the `filter_query` method that takes a search query as input, uses the prompt to generate a response from the `ChatGPT` model, and returns the filtered query.
sweepai/agents/filter_agent.py
✓ Edit
Check sweepai/agents/filter_agent.py with contents:
Ran GitHub Actions for da604ba2c876a82460d66c6672ccf8eb3c69c39e:
• black: ✓
sweepai/utils/ticket_utils.py
✓ https://github.com/sweepai/sweep/commit/c811ac000518981cf641a4baa77a6960595559e4 Edit
Modify sweepai/utils/ticket_utils.py with contents:
• Import the `FilterBot` class from `filter_agent.py`.
• Inside the `prep_snippets` function, before the search query is passed into the lexical search, pass it through the `FilterBot` to filter out unnecessary terms. Replace the existing search query with the filtered query.
--- +++ @@ -16,6 +16,7 @@ from sweepai.utils.chat_logger import discord_log_error from sweepai.utils.event_logger import posthog from sweepai.utils.github_utils import ClonedRepo +from sweepai.agents.filter_agent import FilterBot from sweepai.utils.progress import TicketProgress from sweepai.utils.str_utils import total_number_of_snippet_tokens @@ -40,7 +41,9 @@ for snippet in snippets: snippet.file_path = snippet.file_path[len(cloned_repo.cached_dir) + 1 :] - content_to_lexical_score = search_index(query, lexical_index) + filter_bot = FilterBot() + filtered_query = filter_bot.filter_query(query)[0] + content_to_lexical_score = search_index(filtered_query, lexical_index) snippet_to_key = ( lambda snippet: f"{snippet.file_path}:{snippet.start}:{snippet.end}" )
sweepai/utils/ticket_utils.py
✓ Edit
Check sweepai/utils/ticket_utils.py with contents:
Ran GitHub Actions for c811ac000518981cf641a4baa77a6960595559e4:
sweepai/agents/filter_agent_test.py
✓ https://github.com/sweepai/sweep/commit/f25dae8b531ee4984790efa66924f10fba58382d Edit
Create sweepai/agents/filter_agent_test.py with contents:
• Create a new file `filter_agent_test.py` in the `sweepai/agents/` directory.
• Import the necessary modules and classes. This will include `pytest` and `FilterBot` from `filter_agent.py`.
• Write unit tests for the `FilterBot` class. The tests should cover different types of search queries and ensure that the `FilterBot` correctly filters out unnecessary terms.
sweepai/agents/filter_agent_test.py
✓ Edit
Check sweepai/agents/filter_agent_test.py with contents:
Ran GitHub Actions for f25dae8b531ee4984790efa66924f10fba58382d:
• Vercel Preview Comments: ✓
• black: ✓
I have finished reviewing the code for completeness. I did not find errors for sweep/create_a_new_agent_to_be_used_in_ticket
.
💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request. Join Our Discord
Details
The agent should filter unnecessary terms out of the search query to be sent into lexical search. Use a prompt to do this, using name_agent.py as a reference
Checklist
- [X] Create `sweepai/agents/filter_agent.py` ✓ https://github.com/sweepai/sweep/commit/da604ba2c876a82460d66c6672ccf8eb3c69c39e [Edit](https://github.com/sweepai/sweep/edit/sweep/create_a_new_agent_to_be_used_in_ticket/sweepai/agents/filter_agent.py) - [X] Running GitHub Actions for `sweepai/agents/filter_agent.py` ✓ [Edit](https://github.com/sweepai/sweep/edit/sweep/create_a_new_agent_to_be_used_in_ticket/sweepai/agents/filter_agent.py) - [X] Modify `sweepai/utils/ticket_utils.py` ✓ https://github.com/sweepai/sweep/commit/c811ac000518981cf641a4baa77a6960595559e4 [Edit](https://github.com/sweepai/sweep/edit/sweep/create_a_new_agent_to_be_used_in_ticket/sweepai/utils/ticket_utils.py#L23-L26) - [X] Running GitHub Actions for `sweepai/utils/ticket_utils.py` ✓ [Edit](https://github.com/sweepai/sweep/edit/sweep/create_a_new_agent_to_be_used_in_ticket/sweepai/utils/ticket_utils.py#L23-L26) - [X] Create `sweepai/agents/filter_agent_test.py` ✓ https://github.com/sweepai/sweep/commit/f25dae8b531ee4984790efa66924f10fba58382d [Edit](https://github.com/sweepai/sweep/edit/sweep/create_a_new_agent_to_be_used_in_ticket/sweepai/agents/filter_agent_test.py) - [X] Running GitHub Actions for `sweepai/agents/filter_agent_test.py` ✓ [Edit](https://github.com/sweepai/sweep/edit/sweep/create_a_new_agent_to_be_used_in_ticket/sweepai/agents/filter_agent_test.py)