Feat: Add GitHub Tool for Repository Interaction#1032
Open
oomis wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces Langchain::Tool::Github, enabling AI Agents to interact directly with GitHub repositories.
As the usage of Langchain.rb grows for developer-focused assistants (e.g., "Triage these issues" or "Explain this code"), having a native GitHub integration is essential. This implementation bridges that gap, allowing agents to retrieve context from issues, pull requests, and raw file content.
Features
Issue Listing: Fetch recent open issues for repository analysis.
Pull Request Retrieval: Get details, state, and body of specific PRs.
File Content Reading: Retrieve raw file content (Base64 decoded) for code analysis workflows.
Implementation Details
OpenAI Function Calling: Implemented using the define_function DSL, ensuring full compatibility with OpenAI's tool schema generation.
Lazy Loading: Uses depends_on "octokit" to ensure the gem is only loaded when the tool is initialized, keeping the core library lightweight.
Consistent Return Types: Returns Langchain::ToolResponse objects, maintaining consistency with the recent refactoring of other tools (e.g., Calculator).
Usage Example