Skip to main content

A CLI utility for aggregating file contents

Project description

Code Promptify

Code-Promptify is a command-line utility for aggregating code repository contents into a single string based on include and exclude patterns. It also provides metadata information, such as token count and billable characters. It is designed to help you prepare prompts for large language models (LLMs). The output is written to a file and also copied to your clipboard automatically.

Note: To count tokens, this tool uses the OpenAI tiktoken tokenizer library and should give you accurate results for most GPT models. For other models (Gemini, Llama, Mistral, etc.) the token count may not be 100% precise but it will be a good approximation. That is because the exact token count depends on the specific tokenizer used by the model, which differs among models.

See example_output.md for what the output looks like for this repo when running with default settings.

Example metadata output:

Field Value
Tokenizer openai/tiktoken
Token Count 4763
Character Count 15695

Features

  • Aggregate file contents based on include and exclude patterns (glob strings)
  • Automatically ignores virtual environment files
  • Option to ignore empty files
  • Output results to a file and clipboard

Installation using PIP

To install promptify, simply run:

pip install code-promptify

Installation from Source

To install Promptify, follow these steps:

  1. Clone the repository:

    git clone https://github.com/vmehmeri/promptify.git
    cd promptify
    
  2. Install the package and its dependencies:

    pip install -e . -r requirements.txt
    

Usage

After installation, you can run Promptify using the following command:

promptify [args]

Arguments

  • --include: File patterns to include (default: ["*.py", "*.html", "*.js", "*.css", "*.json", "*.yaml", "*.txt", "*.md"])
  • --exclude: File patterns to exclude (default: ["*.pyc", "*egg-info*", "*tmp*"])
  • --ignore-empty: Flag to Ignore empty files (default: False)

Examples

  1. Use default settings:

    promptify
    
  2. Include only Python and JavaScript files:

    promptify --include "*.py" "*.js"
    
  3. Exclude test files and ignore empty files:

    promptify --exclude "*test*" --ignore-empty
    

Output

See example_output.md

Dependencies

  • pyperclip
  • tabulate
  • token-count

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for 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

code_promptify-0.3.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

code_promptify-0.3.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: code_promptify-0.3.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for code_promptify-0.3.0.tar.gz
Algorithm Hash digest
SHA256 81c2ed7a99a079ed60aea356285e4656dd3b9ec36b379f9554cfe2f4a8d31f51
MD5 48534ff428e0bb2b01d2445b98343d74
BLAKE2b-256 82322458c99d2dfd8af2f551671f3e3c8e7e4e522e7f60f4841c2487fa1f24a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for code_promptify-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 500a02ae2e6b0b54f98fb9500169589ce716be6bc2904c225bab002ca07b9675
MD5 53aee309a44bef23bd598b82d376a9db
BLAKE2b-256 31c4198215d3b050078c4b060f1268d0f4a44a2e7f0f96aea4998ab8e0e22e7c

See more details on using hashes here.

Supported by

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