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:

Added version to 0.4.0

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.3.0.tar.gz (43.8 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.3.0-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for chunkwrap-0.3.0.tar.gz
Algorithm Hash digest
SHA256 578c0627cec1216369375140c5ba075771873920871fbe9098d328a025b2701b
MD5 cd8666928fe7101e9fc08bf53a79a399
BLAKE2b-256 9f65890494b0e9ae8c3e8ae151db55a12c600023ed0e899309523e295e39e31f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chunkwrap-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 29.1 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d2adbb148282fc0ec821b2356603080a8745c92fa4c68ab97e2ef0af401dac6a
MD5 355cc9876b12d1072f96b15e3cf42c6b
BLAKE2b-256 3d59a68d99de0103259064f70e373432643e45ce6e5b7b5a34d2384eafa7f6ef

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