Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions libs/langchain/langchain/tools/github/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


class GitHubAction(BaseTool):
"""Tool for interacting with the GitHub API."""
"Tool for interacting with the GitHub API.\n\nTo use this tool, you must first set as environment variables:\n GITHUB_API_TOKEN\n GITHUB_REPOSITORY -> format: {owner}/{repo}\n\n"""

api_wrapper: GitHubAPIWrapper = Field(default_factory=GitHubAPIWrapper)
mode: str
Expand All @@ -29,4 +29,9 @@ 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:
if run_manager:
run_manager.error(f'Error occurred during GitHub API operation: {e}')
return str(e)