Giving language models context of your codebase
Project description
code-payload
Condense and summarize a codebase for passing to an LLM as context.
Features
- Token-based Summarization: Summarizes content based on token counts, making it suitable for language models.
- Flexible Configuration: Supports configuration through YAML files, environment variables, and CLI arguments.
- Rich CLI Interface: Use the CLI to interact with your projects, including rendering Jinja2 templates.
- Customizable Templates: Generate custom summaries or reports using Jinja2 templates.
Installation
Clone the repository and install dependencies:
git clone https://github.com/your-repo/code-payload.git
cd code-payload
pip install -r requirements.txt
Usage
Command Line Interface (CLI)
The CLI provides a way to process a project directory and output a summary.
python src/code_payload/cli.py --help
Example Usage
To process a project directory and output a JSON summary:
python src/code_payload/cli.py /path/to/your/project
To override the file extensions to include:
python src/code_payload/cli.py /path/to/your/project --include-extensions .py,.js,.md
To use a custom template:
python src/code_payload/cli.py /path/to/your/project --render-args template_input=readme_summary.j2
Configuration
Configuration can be set in a YAML file, through environment variables, or via CLI arguments.
Example YAML Configuration:
project:
root: "./"
file_handling:
max_file_size: 100000
max_summary_length: 5000
exclude:
directories:
- ".git"
- "__pycache__"
- "venv"
- "env"
- "node_modules"
extensions:
- ".pyc"
- ".pyo"
- ".pyd"
- ".db"
- ".log"
- ".sqlite3"
include:
extensions:
- ".py"
- ".js"
- ".jsx"
- ".ts"
- ".tsx"
- ".html"
- ".css"
- ".json"
- ".md"
output:
format: "json"
file: "output.json"
logging:
level: "INFO"
tokens:
max_tokens: 1000
Custom Templates
Two example templates are provided:
- readme_summary.j2: Generates a Markdown summary.
- html_report.j2: Generates an HTML report.
To use a custom template:
python src/code_payload/cli.py /path/to/your/project --render-args template_input=html_report.j2
Contributing
Please feel free to fork this repository and submit pull requests.
License
MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file code_payload-0.1.0.tar.gz
.
File metadata
- Download URL: code_payload-0.1.0.tar.gz
- Upload date:
- Size: 23.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffdb88942996cfc2331217fe5390834972a6e5dc058d53d6ce06196e8a97aae1 |
|
MD5 | 9f0742868237240565f1ee41466747a9 |
|
BLAKE2b-256 | 13e9e0b0809e7f8e71e32092c947bae4c538e519290039c9f645b5cd7c688cbe |
File details
Details for the file code_payload-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: code_payload-0.1.0-py3-none-any.whl
- Upload date:
- Size: 23.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d0e8419631453b771c66f576d8cd8f0716cb332321a47d9f8022c06c63b493b |
|
MD5 | 376407886453354f9da11778a49aff62 |
|
BLAKE2b-256 | db602a03ebb7d443f31898f29606b37b67d32f5d6457f027a108cc62d84721b1 |