New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sweep: create a new agent to be used in ticket_utils.py #2661
Comments
🚀 Here's the PR! #2766See Sweep's progress at the progress dashboard! 💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID:
f85850415a )Actions (click)
Sandbox Execution ✓Here are the sandbox execution logs prior to making any changes: Sandbox logs for
|
@file_cache() | |
def prep_snippets( | |
cloned_repo: ClonedRepo, | |
query: str, |
sweep/sweepai/agents/name_agent.py
Lines 5 to 28 in 1bc1b31
prompt = """\ | |
<old_code> | |
{old_code} | |
</old_code> | |
{snippets} | |
For each of the {count} code snippets above, we want to create function names. We must not have duplicates of the existing function names as follows: | |
{existing_names} | |
Generate a function name for each of these in the below format. Use the context from the old_code and snippets to generate function names that clearly state what the function does. Optimize for readability, clarity, and similarity to the existing function names. | |
<function_name> | |
name_of_function | |
</function_name> | |
...""" | |
def serialize_method_name(method_name): | |
# handles '1. "method_name"' -> 'method_name' | |
if "." in method_name: | |
return method_name.split(". ")[-1].strip('"') | |
return method_name.strip().strip('"') | |
class NameBot(ChatGPT): |
Step 2: ⌨️ Coding
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.
- Running GitHub Actions for
sweepai/agents/filter_agent.py
✓ Edit
Check sweepai/agents/filter_agent.py with contents:Ran GitHub Actions for da604ba2c876a82460d66c6672ccf8eb3c69c39e:
• black: ✓
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}" )
- Running GitHub Actions for
sweepai/utils/ticket_utils.py
✓ Edit
Check sweepai/utils/ticket_utils.py with contents:Ran GitHub Actions for c811ac000518981cf641a4baa77a6960595559e4:
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.
- Running GitHub Actions for
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: ✓
Step 3: 🔁 Code Review
I have finished reviewing the code for completeness. I did not find errors for sweep/create_a_new_agent_to_be_used_in_ticket
.
🎉 Latest improvements to Sweep:
- We just released a dashboard to track Sweep's progress on your issue in real-time, showing every stage of the process – from search to planning and coding.
- Sweep uses OpenAI's latest Assistant API to plan code changes and modify code! This is 3x faster and significantly more reliable as it allows Sweep to edit code and validate the changes in tight iterations, the same way as a human would.
- Try using the GitHub issues extension to create Sweep issues directly from your editor! GitHub Issues and Pull Requests.
💡 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
sweepai/agents/filter_agent.py
✓ da604ba Editsweepai/agents/filter_agent.py
✓ Editsweepai/utils/ticket_utils.py
✓ c811ac0 Editsweepai/utils/ticket_utils.py
✓ Editsweepai/agents/filter_agent_test.py
✓ f25dae8 Editsweepai/agents/filter_agent_test.py
✓ EditThe text was updated successfully, but these errors were encountered: