Tool

Ingest GitHub Repositories and Issues

LlamaIndex reader that loads GitHub repo files, issues, and collaborators into documents via PAT or GitHub App auth.

Works with github

70
Spark score
out of 100
Updated 2 days ago
Version 0.14.23
Models

Add to Favorites

Why it matters

Integrate GitHub repositories, issues, and collaborators into your data pipelines. This asset enables efficient data extraction and indexing for further analysis or retrieval.

Outcomes

What it gets done

01

Load data from GitHub repositories with advanced filtering options.

02

Extract information from GitHub issues and collaborator data.

03

Support for Personal Access Tokens and GitHub App authentication for secure access.

04

Index GitHub content for use in retrieval-augmented generation (RAG) systems.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-reader-readers-github | bash

Overview

LlamaIndex Readers Integration: Github

A LlamaIndex reader package with three readers for GitHub: repositories, issues, and collaborators. The Repository Reader supports directory/extension/path filtering and a custom file-processing callback, authenticated via a personal access token or a GitHub App. Reach for it when building retrieval or codebase-chat tools that need GitHub repo content indexed with fine control over which files are included, rather than a full unfiltered clone.

What it does

The GitHub Readers package for LlamaIndex bundles three separate readers for pulling GitHub data into LlamaIndex documents: a Repository Reader, an Issues Reader, and a Collaborators Reader. Install with pip install llama-index-readers-github. The Repository Reader walks a repo and turns its files into documents, with options to include or exclude specific directories, file extensions, or file paths, plus a custom callback for per-file processing logic - for example skipping files over a given size or matching a pattern like "test" in the path.

When to use - and when NOT to

Use it when you need to feed GitHub repository content into a LlamaIndex index for retrieval or Q&A, filtering down to relevant source files or docs rather than pulling in an entire repo including binaries and generated notebooks. The bundled filter_file_extensions and filter_file_paths options are built for exactly this: exclude images, JSON, and notebooks, or scope to only the files that matter. It is not the right fit for a one-off single-file fetch, and this description covers only the Repository Reader's documented behavior in depth - the Issues and Collaborators readers ship in the same package but are named without further detail here.

Inputs and outputs

Inputs are a GitHub owner/repo pair plus an authenticated GithubClient, with optional directory, extension, or path filters and an optional custom callback that receives a file path and file size and returns whether to process it. Output is a list of LlamaIndex Document objects: documents = reader.load_data(branch="main").

Integrations

Two authentication modes are supported. A Personal Access Token, generated under GitHub account settings, can be passed directly to GithubClient(github_token="ghp_your_token_here") or picked up automatically from the GITHUB_TOKEN environment variable. GitHub App authentication instead uses an app ID, a PEM private key, and an installation ID via GitHubAppAuth, and needs the extra pip install llama-index-readers-github[github-app]. The source positions GitHub App auth as offering better security (tokens auto-expire after one hour), fine-grained repository-level permissions, organization-wide installs across multiple repos, and audit trails attributed to the app rather than an individual user - versus a PAT's simpler but broader-blast-radius token.

Who it's for

Teams building retrieval or chat-over-codebase tools who need repository content indexed without manually cloning and parsing files, and who want control over what gets pulled in - docs only, tests excluded, binaries excluded - rather than ingesting an entire repository indiscriminately. GitHub App auth in particular suits organizations that need per-repo access control and auditability rather than a single shared personal token.

pip install llama-index-readers-github
Source README

LlamaIndex Readers Integration: Github

pip install llama-index-readers-github

The github readers package consists of three separate readers:

  1. Repository Reader
  2. Issues Reader
  3. Collaborators Reader

Authentication

The readers support two authentication methods:

1. Personal Access Token (PAT)

Generate a token under your account settings at https://github.com/settings/tokens

from llama_index.readers.github import GithubClient

### Direct token
client = GithubClient(github_token="ghp_your_token_here")

### Or via environment variable
import os

os.environ["GITHUB_TOKEN"] = "ghp_your_token_here"
client = GithubClient()  # Automatically uses GITHUB_TOKEN

2. GitHub App Authentication

For better security, rate limits, and organization-level access, use GitHub App authentication:

from llama_index.readers.github import GithubClient, GitHubAppAuth

### Load your GitHub App private key
with open("path/to/private-key.pem", "r") as f:
    private_key = f.read()

### Create GitHub App auth handler
app_auth = GitHubAppAuth(
    app_id="123456",  # Your GitHub App ID
    private_key=private_key,  # Private key content (PEM format)
    installation_id="789012",  # Installation ID for the target org/repo
)

### Use with any client
client = GithubClient(github_app_auth=app_auth)

Installation for GitHub App support:

pip install llama-index-readers-github[github-app]

Benefits of GitHub App authentication:

  • Higher rate limits: 5,000 requests/hour per installation (vs 5,000/hour for PAT)
  • Fine-grained permissions: Repository-specific access control
  • Better security: Tokens auto-expire after 1 hour
  • Organization-level: Can be installed across multiple repositories
  • Auditability: Actions attributed to the app, not individual users

Repository Reader

This reader will read through a repo, with options to specifically filter directories, file extensions, file paths, and custom processing logic.

Basic Usage

from llama_index.readers.github import GithubRepositoryReader, GithubClient

client = github_client = GithubClient(github_token=github_token, verbose=False)

reader = GithubRepositoryReader(
    github_client=github_client,
    owner="run-llama",
    repo="llama_index",
    use_parser=False,
    verbose=True,
    filter_directories=(
        ["docs"],
        GithubRepositoryReader.FilterType.INCLUDE,
    ),
    filter_file_extensions=(
        [
            ".png",
            ".jpg",
            ".jpeg",
            ".gif",
            ".svg",
            ".ico",
            "json",
            ".ipynb",
        ],
        GithubRepositoryReader.FilterType.EXCLUDE,
    ),
)

documents = reader.load_data(branch="main")

Advanced Filtering Options

Filter Specific File Paths
### Include only specific files
reader = GithubRepositoryReader(
    github_client=github_client,
    owner="run-llama",
    repo="llama_index",
    filter_file_paths=(
        ["README.md", "src/main.py", "docs/guide.md"],
        GithubRepositoryReader.FilterType.INCLUDE,
    ),
)

### Exclude specific files
reader = GithubRepositoryReader(
    github_client=github_client,
    owner="run-llama",
    repo="llama_index",
    filter_file_paths=(
        ["tests/test_file.py", "temp/cache.txt"],
        GithubRepositoryReader.FilterType.EXCLUDE,
    ),
)
Custom File Processing Callback
def process_file_callback(file_path: str, file_size: int) -> tuple[bool, str]:
    """Custom logic to determine if a file should be processed.

    Args:
        file_path: The full path to the file
        file_size: The size of the file in bytes

    Returns:
        Tuple of (should_process: bool, reason: str)
    """
    # Skip large files
    if file_size > 1024 * 1024:  # 1MB
        return False, f"File too large: {file_size} bytes"

    # Skip test files
    if "test" in file_path.lower():
        return False, "Skipping test files"

    #

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.