Repository Classifier
Classifies GitHub repositories by project type using a cascade: Ground Truth → File-type inference → Heuristic or LLM. Built-in classifiers: PHP, Python, JavaScript.
Installation
pip install repo-classifier
From source (uses uv):
git clone https://github.com/samhsu-dev/repo_classifier.git
cd repo_classifier
uv sync
Usage
from repo_classifier import classify_repository_heuristic, classify_repository_aimodel, CLASSIFIERS
# Heuristic (no API key)
results = classify_repository_heuristic(
"https://github.com/laravel/laravel",
classifier=CLASSIFIERS.php, # or "php"
top_n=3,
)
# {"Framework": 0.95, ...}
# LLM: set api_key and model_name (provider/model, e.g. openai/gpt-4o); optional: docs/.env (see docs/.env.example)
results = classify_repository_aimodel(
"https://github.com/django/django",
classifier=CLASSIFIERS.python,
model_name="openai/gpt-4o",
api_key="sk-...",
)
Advanced usage
Custom classifier — register a name → type/weight map; then pass the name to classify_repository_heuristic or classify_repository_aimodel.
from repo_classifier import register_classifier, classify_repository_heuristic
register_classifier("game", {"Game Engine": {"engine": 10, "game": 8}, "Tool": {"editor": 10}})
classify_repository_heuristic("https://github.com/...", classifier="game", top_n=2)
Classifier from file or module — File format: TYPE: TypeName then keyword: weight per line. create_classifier_from_file(path) returns a config dict; pass to classification or register_classifier. load_classifier_from_module(module_path, attribute_name=None) registers config(s) from a module.
from repo_classifier import create_classifier_from_file, register_classifier, load_classifier_from_module
config = create_classifier_from_file("path/to/types.txt")
register_classifier("my_domain", config)
# or: load_classifier_from_module("path/to/classifiers.py")
LLM with custom type list — pass a list of type names; no registration.
classify_repository_aimodel(
"https://github.com/...",
classifier=["Web App", "API", "Library", "CLI"],
model_name="openai/gpt-4o-mini",
api_key="sk-...",
)
Ground truth and evaluation — load_ground_truth(path) / save_ground_truth(path, dict); add_ground_truth_entry(url, type); evaluate_classifier(name, truth_dict) returns metrics (accuracy, precision, recall, f1).
from repo_classifier import load_ground_truth, evaluate_classifier
truth = load_ground_truth("path/to/ground_truth.json")
metrics = evaluate_classifier("php", truth)
Documentation
| Doc | Purpose |
|---|---|
| docs/demo.ipynb | End-to-end demo; configure via docs/.env (see docs/.env.example) |
| docs/idea.md | Concepts, architecture, data flow, cascade pipeline, scenarios |
| docs/design.md | Public/internal API, validation, errors, cascade behaviour |
| docs/impl.md | LLM integration (litellm), prompt and response handling |
Development
Uses uv. From the repo root:
uv sync
uv run pytest
uv run pytest --cov=repo_classifier
Lint/format: uv run black, uv run isort, uv run mypy, uv run pylint (see pyproject.toml).
License
MIT
Metadata
Release files for repo-classifier 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| repo_classifier-1.0.1.tar.gz | 315.0 kB | Without provenance | Details for repo_classifier-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| repo_classifier-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for repo_classifier-1.0.1-py3-none-any.whl |
Total release size: 336.2 kB
Release files / repo_classifier-1.0.1.tar.gz
| Download URL | repo_classifier-1.0.1.tar.gz |
|---|---|
| Size | 315.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8fcc9ff54558b132316ec252e38ceed9ef66328140ecdae41dd6b94bdc9617b2
|
|
BLAKE2b-256 checksum How to use checksums |
a417bdeba68d3d91555cf55c4cd1ccb64777458d30e1b5fae25392b41b528930
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / repo_classifier-1.0.1-py3-none-any.whl
| Download URL | repo_classifier-1.0.1-py3-none-any.whl |
|---|---|
| Size | 21.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b3f231d23ec8456fd54f0eb9c52c5d08f966486f56f2057f3f7046e83e4c130b
|
|
BLAKE2b-256 checksum How to use checksums |
43730a6e1b509b5332e24c55c5bf46415c0561a4721b9f843fcfdd3a2e99db6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for repo-classifier 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.