Skip to content
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

Open
6 tasks done
wwzeng1 opened this issue Nov 30, 2023 · 1 comment
Open
6 tasks done

Sweep: create a new agent to be used in ticket_utils.py #2661

wwzeng1 opened this issue Nov 30, 2023 · 1 comment
Labels
sweep Assigns Sweep to an issue or pull request.

Comments

@wwzeng1
Copy link
Contributor

wwzeng1 commented Nov 30, 2023

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
  • Create sweepai/agents/filter_agent.pyda604ba Edit
  • Running GitHub Actions for sweepai/agents/filter_agent.pyEdit
  • Modify sweepai/utils/ticket_utils.pyc811ac0 Edit
  • Running GitHub Actions for sweepai/utils/ticket_utils.pyEdit
  • Create sweepai/agents/filter_agent_test.pyf25dae8 Edit
  • Running GitHub Actions for sweepai/agents/filter_agent_test.pyEdit
@wwzeng1 wwzeng1 added the sweep Assigns Sweep to an issue or pull request. label Nov 30, 2023
Copy link
Contributor

sweep-nightly bot commented Nov 30, 2023

🚀 Here's the PR! #2766

See 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)

  • ↻ Restart Sweep

Sandbox Execution ✓

Here are the sandbox execution logs prior to making any changes:

Sandbox logs for 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.


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description.

@file_cache()
def prep_snippets(
cloned_repo: ClonedRepo,
query: str,

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.pyda604ba 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.
  • Running GitHub Actions for sweepai/agents/filter_agent.pyEdit
Check sweepai/agents/filter_agent.py with contents:

Ran GitHub Actions for da604ba2c876a82460d66c6672ccf8eb3c69c39e:
• black:

  • Modify sweepai/utils/ticket_utils.pyc811ac0 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}"
     )
  • Running GitHub Actions for sweepai/utils/ticket_utils.pyEdit
Check sweepai/utils/ticket_utils.py with contents:

Ran GitHub Actions for c811ac000518981cf641a4baa77a6960595559e4:

  • Create sweepai/agents/filter_agent_test.pyf25dae8 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.
  • Running GitHub Actions for sweepai/agents/filter_agent_test.pyEdit
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment