Skip to main content

A project that splits files and copies them to paste buffer with context for an LLM.

Reason this release was yanked:

version did not work on fresh machine

Project description

chunkwrap

A Python utility for splitting large files into manageable chunks and wrapping them with custom prompts for Large Language Model (LLM) processing.

Overview

chunkwrap helps you process large files with LLMs by automatically splitting them into smaller chunks and wrapping each chunk with your specified prompt. It maintains state between runs, so you can process one chunk at a time without losing track of your progress.

Features

  • Automatic chunking: Split files into configurable chunk sizes (default 10,000 characters)
  • State management: Remembers which chunk you're on between runs
  • Clipboard integration: Automatically copies wrapped chunks to your clipboard
  • Custom prompts: Use different prompts for regular chunks vs. the final chunk
  • Progress tracking: Shows current chunk number and total chunks

Installation

  1. Clone or download the script
  2. Install the required dependency:
    pip install pyperclip
    

Usage

Basic Usage

python chunkwrap.py --prompt "Analyze this code:" --file myfile.txt

Advanced Usage

# Custom chunk size
python chunkwrap.py --prompt "Review this code:" --file large_file.py --size 5000

# Different prompt for the last chunk
python chunkwrap.py --prompt "Analyze this code chunk:" --file code.py --lastprompt "Analyze this final code chunk and provide a summary:"

# Reset state to start over
python chunkwrap.py --reset

Command Line Arguments

  • --prompt (required): The prompt text to wrap around each chunk
  • --file (required): Path to the file you want to process
  • --lastprompt (optional): Different prompt for the final chunk
  • --size (optional): Chunk size in characters (default: 10,000)
  • --reset (optional): Reset the chunk counter and start from the beginning

How It Works

  1. First run: Reads your file, splits it into chunks, wraps the first chunk with your prompt, and copies it to clipboard
  2. Subsequent runs: Continues from where you left off, processing the next chunk
  3. State tracking: Uses a .chunkwrap_state file to remember your progress
  4. Completion: Notifies you when all chunks are processed

Example Workflow

# Start processing a large Python file
python chunkwrap.py --prompt "Please review this Python code for bugs:" --file large_script.py

# Output: "Chunk 1 of 5 is now in the paste buffer. Run this script again for the next chunk."
# Paste into your LLM, get response, then run again...

python chunkwrap.py --prompt "Please review this Python code for bugs:" --file large_script.py

# Output: "Chunk 2 of 5 is now in the paste buffer. Run this script again for the next chunk."
# Continue until all chunks are processed...

# When done with this file, reset for a new file
python chunkwrap.py --reset

Output Format

Each chunk is wrapped in triple quotes with your prompt:

Your prompt here (chunk 1 of 3)
"""
[chunk content here]
"""

The final chunk omits the chunk counter and uses --lastprompt if provided.

State File

chunkwrap creates a .chunkwrap_state file in the current directory to track progress. Delete this file or use --reset to start over with a new file or prompt.

Use Cases

  • Processing large codebases with LLMs
  • Analyzing lengthy documents in sections
  • Breaking down large text files for review
  • Sequential processing of any large text content

Requirements

  • Python 3.6+
  • pyperclip library

License

This project is licensed under the GNU General Public License v3.0. See the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chunkwrap-0.4.0.tar.gz (43.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chunkwrap-0.4.0-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

Details for the file chunkwrap-0.4.0.tar.gz.

File metadata

  • Download URL: chunkwrap-0.4.0.tar.gz
  • Upload date:
  • Size: 43.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for chunkwrap-0.4.0.tar.gz
Algorithm Hash digest
SHA256 d622c7c28258ff6c7c35761568bb1e5730b4a879fd2c1e9a2fad5ce20458848a
MD5 e193150849e000ac91b255fefcc7ce62
BLAKE2b-256 1f5876db5cf1b1aa903b271c496103c768d661546409abd7d450f4f789e6f6e6

See more details on using hashes here.

File details

Details for the file chunkwrap-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: chunkwrap-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 29.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for chunkwrap-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c0f6b128aed500703f60329962e17e3121f905b840f8ce8d807ef0605746ffb
MD5 58c3cc8e8d1a3117be1befad1397276c
BLAKE2b-256 3813e29e853aa45eacbc7e1fc6335a2a29c681d58d8c8c277b51e5431984e0f4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page