From d32ffc1a2023401e5c840d7869cfe31a37a7bcf4 Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Sun, 23 Jun 2024 00:23:42 +0000 Subject: [PATCH 1/3] Snippet fusing logic --- sweepai/chat/api.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/sweepai/chat/api.py b/sweepai/chat/api.py index 42beeafeb8..623524c55d 100644 --- a/sweepai/chat/api.py +++ b/sweepai/chat/api.py @@ -392,6 +392,20 @@ def search_codebase( yield f"{message} (optimized query: {query})", snippets else: yield message, snippets + new_snippets = [] + for snippet in snippets: + for new_snippet in new_snippets: + if new_snippet.file_path == snippet.file_path: + if new_snippet.end + 1 == snippet.start: + new_snippet.end = snippet.end + break + elif new_snippet.start - 1 == snippet.end: + new_snippet.start = snippet.start + break + else: + new_snippets.append(snippet) + snippets = new_snippets + yield "Fused snippets.", snippets logger.debug(f"Preparing snippets took {timer.time_elapsed} seconds") return snippets @@ -562,18 +576,7 @@ def stream_state( user_message = initial_user_message fetched_snippets = snippets - new_messages = [ - Message( - content=snippets_message, - role="function", - function_call={ - "function_name": "search_codebase", - "function_parameters": {}, - "is_complete": True, - "snippets": deepcopy(snippets) - } - ) - ] if len(messages) <= 2 else [] + new_messages = [] yield new_messages From f5430633b16b3736280558e04fb98a64837e4b96 Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Sun, 23 Jun 2024 00:24:58 +0000 Subject: [PATCH 2/3] Added snippet fusing --- sweepai/chat/api.py | 16 ++-------------- sweepai/core/entities.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/sweepai/chat/api.py b/sweepai/chat/api.py index 623524c55d..e8e0c0214d 100644 --- a/sweepai/chat/api.py +++ b/sweepai/chat/api.py @@ -22,7 +22,7 @@ from sweepai.config.client import SweepConfig from sweepai.config.server import CACHE_DIRECTORY, DOCKER_ENABLED, GITHUB_APP_ID, GITHUB_APP_PEM from sweepai.core.chat import ChatGPT, call_llm -from sweepai.core.entities import FileChangeRequest, Message, Snippet +from sweepai.core.entities import FileChangeRequest, Message, Snippet, fuse_snippets from sweepai.core.pull_request_bot import get_pr_summary_for_chat from sweepai.core.review_utils import split_diff_into_patches from sweepai.dataclasses.check_status import CheckStatus, gha_to_check_status, gha_to_message @@ -392,19 +392,7 @@ def search_codebase( yield f"{message} (optimized query: {query})", snippets else: yield message, snippets - new_snippets = [] - for snippet in snippets: - for new_snippet in new_snippets: - if new_snippet.file_path == snippet.file_path: - if new_snippet.end + 1 == snippet.start: - new_snippet.end = snippet.end - break - elif new_snippet.start - 1 == snippet.end: - new_snippet.start = snippet.start - break - else: - new_snippets.append(snippet) - snippets = new_snippets + snippets = fuse_snippets(snippets) yield "Fused snippets.", snippets logger.debug(f"Preparing snippets took {timer.time_elapsed} seconds") return snippets diff --git a/sweepai/core/entities.py b/sweepai/core/entities.py index 457b8baef5..cc89f2d278 100644 --- a/sweepai/core/entities.py +++ b/sweepai/core/entities.py @@ -422,6 +422,20 @@ def from_file( **kwargs, ) +def fuse_snippets(snippets: list[Snippet]) -> list[Snippet]: + new_snippets = [] + for snippet in snippets: + for new_snippet in new_snippets: + if new_snippet.file_path == snippet.file_path: + if new_snippet.end + 1 == snippet.start: + new_snippet.end = snippet.end + break + elif new_snippet.start - 1 == snippet.end: + new_snippet.start = snippet.start + break + else: + new_snippets.append(snippet) + return new_snippets class NoFilesException(Exception): def __init__(self, message="Sweep could not find any files to modify"): From 29c803bec44de893b274e82057376e30ef2d34be Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Sun, 23 Jun 2024 00:27:33 +0000 Subject: [PATCH 3/3] Remove pypi --- .github/workflows/{pypi.yml => pypi.yml.removed} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{pypi.yml => pypi.yml.removed} (100%) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml.removed similarity index 100% rename from .github/workflows/pypi.yml rename to .github/workflows/pypi.yml.removed