From 6fbcf54c9a7858d40ed421cff98b453f3e1f90f3 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Sun, 28 Jan 2024 13:16:19 +0000 Subject: [PATCH 1/8] feat: Updated libs/langchain/langchain/tools/githu --- libs/langchain/langchain/tools/github/tool.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libs/langchain/langchain/tools/github/tool.py b/libs/langchain/langchain/tools/github/tool.py index ec67fd2b3357b..adf296223abb4 100644 --- a/libs/langchain/langchain/tools/github/tool.py +++ b/libs/langchain/langchain/tools/github/tool.py @@ -29,4 +29,11 @@ def _run( run_manager: Optional[CallbackManagerForToolRun] = None, ) -> str: """Use the GitHub API to run an operation.""" - return self.api_wrapper.run(self.mode, instructions) + try: + return self.api_wrapper.run(self.mode, instructions) + except Exception as e: + error_msg = f'Error occurred during GitHub API operation: {e}' + if run_manager: + run_manager.error(error_msg) + print(error_msg) + raise e From 2dbd0c4eedf7eca317dd337034c746abc87a94bc Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Sun, 28 Jan 2024 13:17:07 +0000 Subject: [PATCH 2/8] feat: Updated libs/langchain/langchain/utilities/g --- libs/langchain/langchain/utilities/github.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libs/langchain/langchain/utilities/github.py b/libs/langchain/langchain/utilities/github.py index 7ef1c2e4b78c1..ab40b471fae2f 100644 --- a/libs/langchain/langchain/utilities/github.py +++ b/libs/langchain/langchain/utilities/github.py @@ -95,6 +95,20 @@ def parse_issues(self, issues: List[Issue]) -> List[dict]: return parsed def get_issues(self) -> str: + try: + issues = self.github_repo_instance.get_issues(state="open") + if issues.totalCount > 0: + parsed_issues = self.parse_issues(issues) + parsed_issues_str = ( + "Found " + str(len(parsed_issues)) + " issues:\n" + str(parsed_issues) + ) + return parsed_issues_str + else: + return "No open issues available" + except Exception as e: + error_msg = f'Error occurred during issue retrieval: {e}' + print(error_msg) + return error_msg """ Fetches all open issues from the repo From ff997b4e252949467b1822e4c97ce32fef7c3fb6 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Sun, 28 Jan 2024 13:18:10 +0000 Subject: [PATCH 3/8] feat: Updated libs/langchain/langchain/utilities/g --- libs/langchain/langchain/utilities/github.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/langchain/langchain/utilities/github.py b/libs/langchain/langchain/utilities/github.py index ab40b471fae2f..672c76925847a 100644 --- a/libs/langchain/langchain/utilities/github.py +++ b/libs/langchain/langchain/utilities/github.py @@ -132,8 +132,11 @@ def get_issue(self, issue_number: int) -> Dict[str, Any]: Parameters: issue_number(int): The number for the github issue Returns: - dict: A doctionary containing the issue's title, - body, and comments as a string + dict: A dictionary containing the issue's title, body, and comments as a string + except Exception as e: + error_msg = f'Error occurred during issue retrieval: {e}' + print(error_msg) + return error_msg """ issue = self.github_repo_instance.get_issue(number=issue_number) page = 0 From 4176235665a41ff8ffffbed6c7d875600eb37208 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Sun, 28 Jan 2024 13:18:51 +0000 Subject: [PATCH 4/8] feat: Updated libs/langchain/langchain/utilities/g --- libs/langchain/langchain/utilities/github.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/langchain/langchain/utilities/github.py b/libs/langchain/langchain/utilities/github.py index 672c76925847a..3948bb9313e2a 100644 --- a/libs/langchain/langchain/utilities/github.py +++ b/libs/langchain/langchain/utilities/github.py @@ -181,6 +181,9 @@ def create_pull_request(self, pr_query: str) -> str: ) return f"Successfully created PR number {pr.number}" except Exception as e: + error_msg = f'Error occurred during pull request creation: {e}' + print(error_msg) + return error_msg return "Unable to make pull request due to error:\n" + str(e) def comment_on_issue(self, comment_query: str) -> str: From cf96e111e39316b17b3fdf551bbf743cb306c154 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Sun, 28 Jan 2024 13:19:35 +0000 Subject: [PATCH 5/8] feat: Updated libs/langchain/langchain/utilities/g --- libs/langchain/langchain/utilities/github.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/langchain/langchain/utilities/github.py b/libs/langchain/langchain/utilities/github.py index 3948bb9313e2a..0210480783128 100644 --- a/libs/langchain/langchain/utilities/github.py +++ b/libs/langchain/langchain/utilities/github.py @@ -201,7 +201,12 @@ def comment_on_issue(self, comment_query: str) -> str: comment = comment_query[len(str(issue_number)) + 2 :] try: issue = self.github_repo_instance.get_issue(number=issue_number) + if issue: issue.create_comment(comment) + else: + error_msg = 'Failed to create comment: Issue not found' + print(error_msg) + return error_msg return "Commented on issue " + str(issue_number) except Exception as e: return "Unable to make comment due to error:\n" + str(e) From 3ccf96d3f8eb83ab7670b22aafb352ca828ded1c Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Sun, 28 Jan 2024 13:20:15 +0000 Subject: [PATCH 6/8] feat: Updated libs/langchain/langchain/utilities/g --- libs/langchain/langchain/utilities/github.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/langchain/langchain/utilities/github.py b/libs/langchain/langchain/utilities/github.py index 0210480783128..41f0be74f3e10 100644 --- a/libs/langchain/langchain/utilities/github.py +++ b/libs/langchain/langchain/utilities/github.py @@ -237,7 +237,10 @@ def create_file(self, file_query: str) -> str: else: return f"File already exists at {file_path}. Use update_file instead" except Exception as e: - return "Unable to make file due to error:\n" + str(e) + error_msg = f'Error occurred during file creation: {e}' + print(error_msg) + return error_msg + return error_msg def read_file(self, file_path: str) -> str: """ From e5e032d6b238089f6f0fc841f28459f3fe5dad46 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Sun, 28 Jan 2024 13:21:46 +0000 Subject: [PATCH 7/8] feat: Updated libs/langchain/langchain/utilities/g --- libs/langchain/langchain/utilities/github.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/libs/langchain/langchain/utilities/github.py b/libs/langchain/langchain/utilities/github.py index 41f0be74f3e10..b7576a57a6bd0 100644 --- a/libs/langchain/langchain/utilities/github.py +++ b/libs/langchain/langchain/utilities/github.py @@ -272,7 +272,8 @@ def update_file(self, file_query: str) -> str: A success or failure message """ try: - file_path = file_query.split("\n")[0] + try: + file_path = file_query.split("\n")[0] old_file_contents = ( file_query.split("OLD <<<<")[1].split(">>>> OLD")[0].strip() ) @@ -285,6 +286,12 @@ def update_file(self, file_query: str) -> str: old_file_contents, new_file_contents ) + except Exception as e: + error_msg = f'Error occurred during file content comparison: {e}' + print(error_msg) + return error_msg + + try: if file_content == updated_file_content: return ( "File content was not updated because old content was not found." @@ -292,7 +299,13 @@ def update_file(self, file_query: str) -> str: "the current file contents." ) - self.github_repo_instance.update_file( + except Exception as e: + error_msg = f'Error occurred during file update: {e}' + print(error_msg) + return error_msg + + try: + self.github_repo_instance.update_file( path=file_path, message="Update " + file_path, content=updated_file_content, From f0ed112986b81655074fad5a7e6c69d16ed220c3 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Sun, 28 Jan 2024 13:22:25 +0000 Subject: [PATCH 8/8] feat: Updated libs/langchain/langchain/utilities/g --- libs/langchain/langchain/utilities/github.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/langchain/langchain/utilities/github.py b/libs/langchain/langchain/utilities/github.py index b7576a57a6bd0..fadc05f5a76ec 100644 --- a/libs/langchain/langchain/utilities/github.py +++ b/libs/langchain/langchain/utilities/github.py @@ -334,7 +334,9 @@ def delete_file(self, file_path: str) -> str: ) return "Deleted file " + file_path except Exception as e: - return "Unable to delete file due to error:\n" + str(e) + error_msg = f'Error occurred during file deletion: {e}' + print(error_msg) + return error_msg def run(self, mode: str, query: str) -> str: if mode == "get_issues":