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: In repocontextmanager make sure that the snippets are sorted by starting line if two or more snippets are from the same file #2723

Open
2 tasks done
wwzeng1 opened this issue Dec 7, 2023 · 1 comment · May be fixed by #2726
Labels
sweep Assigns Sweep to an issue or pull request.

Comments

@wwzeng1
Copy link
Contributor

wwzeng1 commented Dec 7, 2023

Checklist
  • Modify sweepai/core/context_pruning.py3fe482a Edit
  • Running GitHub Actions for sweepai/core/context_pruning.pyEdit

Flowchart

@wwzeng1 wwzeng1 added the sweep Assigns Sweep to an issue or pull request. label Dec 7, 2023
Copy link
Contributor

sweep-nightly bot commented Dec 7, 2023

Here's the PR! #2726. See Sweep's process at dashboard.

💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: 0d65d0877a)

Actions (click)

  • ↻ Restart Sweep

Sandbox Execution ✓

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

Sandbox logs for 338fc3c
Checking sweepai/core/context_pruning.py for syntax errors... ✅ sweepai/core/context_pruning.py has no syntax errors! 1/1 ✓
Checking sweepai/core/context_pruning.py for syntax errors...
✅ sweepai/core/context_pruning.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.

functions = [
{
"name": "store_file_path",
"parameters": {
"type": "object",
"properties": {
"file_path": {
"type": "string",
"description": "File or directory to store.",
},
"justification": {
"type": "string",
"description": "Justification for store the file_path.",
},
},
"required": ["file_path", "justification"],
},
"description": "Use this to either store an existing file_path or add a new path to paths_in_repo. Only store paths you are certain are relevant to solving the user request. All of the files not listed will be removed from the paths_in_repo. Make sure to store ALL of the files that are referenced in the issue title or description.",
},


Step 2: ⌨️ Coding

  • Modify sweepai/core/context_pruning.py3fe482a Edit
Modify sweepai/core/context_pruning.py with contents:
• Investigate the file to identify the function or method that handles the storage or retrieval of snippets.
• Once the relevant function or method is identified, modify it to sort the snippets by their starting line number when they are from the same file. This can be done by adding a sorting function or modifying an existing one. The sorting function should take the starting line number of each snippet as a key.
• If the snippets are stored in a data structure that does not preserve order (like a set or a dictionary), it may be necessary to change this data structure to a list or a similar data structure that preserves order.
• After the modifications, ensure that the function or method still works as expected with the new sorting feature. This can be done by running the existing tests and adding new ones if necessary.

+++
@@ -8,6 +8,7 @@
from openai.types.beta.thread import Thread
from openai.types.beta.threads.run import Run

+from sandbox.src.sandbox_local import field
from sweepai.agents.assistant_wrapper import client, openai_retry_with_timeout
from sweepai.core.entities import Snippet
from sweepai.logn.cache import file_cache
@@ -116,7 +117,7 @@
current_top_tree: str
snippets: list[Snippet]
snippet_scores: dict[str, float]

  • current_top_snippets: list[Snippet] = []
  • current_top_snippets: list[Snippet] = field(default_factory=list, compare=False)

    @Property
    def top_snippet_paths(self):

  • Running GitHub Actions for sweepai/core/context_pruning.pyEdit
Check sweepai/core/context_pruning.py with contents:

Ran GitHub Actions for 3fe482a57b7ad029d98a217a17f54a0e97ee9c71:
• black:
• Vercel Preview Comments:


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/sort-snippets-by-line.


🎉 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.

💡 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
Labels
sweep Assigns Sweep to an issue or pull request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant