contextualize
contextualize is a package to quickly retrieve and format file contents for use with LLMs.
Installation
You can install the package using pip:
pip install contextualize
Usage (reference.py)
Define FileReference objects for specified file paths and optional ranges.
- set
rangeto a tuple of line numbers to include only a portion of the file, e.g.range=(1, 10) - set
formatto "md" or "xml" to wrap file contents in Markdown code blocks or<file>tags - set
labelto "relative" (default), "name", or "ext" to determine what label is affixed to the enclosing Markdown/XML string- "relative" will use the relative path from the current working directory
- "name" will use the file name only
- "ext" will use the file extension only
Retrieve wrapped contents from the output attribute.
CLI
A CLI (cli.py) is provided to print file contents to the console from the command line.
cat: Prepare and concatenate file referencespaths: Positional arguments for target file(s) or directories--ignore: File(s) to ignore (optional)--format: Output format (mdorxml, default ismd)--label: Label style (relativefor relative file path,namefor file name only,extfor file extension only; default isrelative)
- Example usage:
contextualize cat README.mdwill print the wrapped contents ofREADME.mdto the console with default settings (Markdown format, relative path label).contextualize cat README.md --format xmlwill print the wrapped contents ofREADME.mdto the console with XML format.contextualize cat contextualize/ dev/ README.md --format xmlwill prepare file references for files in thecontextualize/anddev/directories andREADME.md, and print each file's contents (wrapped in corresponding XML tags) to the console.
Related projects
Metadata
Release files for contextualize 0.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 | |
|---|---|---|---|
| contextualize-0.0.1.tar.gz | 15.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| contextualize-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.1 kB
Release files / contextualize-0.0.1.tar.gz
| Download URL | contextualize-0.0.1.tar.gz |
|---|---|
| Size | 15.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1767fc6ae3c621c00c2747edde3d3611a6e3634b358fe2694e8c7058d0108a12
|
|
BLAKE2b-256 checksum How to use checksums |
3c701b580347ce0c8dd3ce7c1ac4d702bcf882246a46237408d54a51a94a267c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.6
|
Release files / contextualize-0.0.1-py3-none-any.whl
| Download URL | contextualize-0.0.1-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
989e217adb04174d8b662488660fccb69862570aa83cb3779ab04fc454c914ad
|
|
BLAKE2b-256 checksum How to use checksums |
ec179654fedecaa90676f2910034d6725e686f4588bfa0b2ab083e49968223f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.6
|