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 diff --git a/sweepai/chat/api.py b/sweepai/chat/api.py index 42beeafeb8..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,6 +392,8 @@ def search_codebase( yield f"{message} (optimized query: {query})", snippets else: yield message, snippets + snippets = fuse_snippets(snippets) + yield "Fused snippets.", snippets logger.debug(f"Preparing snippets took {timer.time_elapsed} seconds") return snippets @@ -562,18 +564,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 diff --git a/sweepai/core/entities.py b/sweepai/core/entities.py index 2a7f28f555..2ec14347b5 100644 --- a/sweepai/core/entities.py +++ b/sweepai/core/entities.py @@ -427,6 +427,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"):