Skip to main content

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 range to a tuple of line numbers to include only a portion of the file, e.g. range=(1, 10)
  • set format to "md" or "xml" to wrap file contents in Markdown code blocks or <file> tags
  • set label to "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 references
    • paths: Positional arguments for target file(s) or directories
    • --ignore: File(s) to ignore (optional)
    • --format: Output format (md or xml, default is md)
    • --label: Label style (relative for relative file path, name for file name only, ext for file extension only; default is relative)
  • Example usage:
    • contextualize cat README.md will print the wrapped contents of README.md to the console with default settings (Markdown format, relative path label).
    • contextualize cat README.md --format xml will print the wrapped contents of README.md to the console with XML format.
    • contextualize cat contextualize/ dev/ README.md --format xml will prepare file references for files in the contextualize/ and dev/ directories and README.md, and print each file's contents (wrapped in corresponding XML tags) to the console.

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)

Source distribution for contextualize 0.0.1
File Size Uploaded
contextualize-0.0.1.tar.gz 15.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for contextualize 0.0.1
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

0.1.0

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page