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 |
Files included: └── . ├── README.md ├── build │ └── lib │ └── promptify │ ├── init.py │ └── main.py ├── example_output.md ├── output.md ├── promptify │ └── init.py └── requirements.txt
Features
- Aggregate file contents based on include and exclude patterns (glob strings)
- Automatically ignores virtual environment files
- Automatically ignores files where an API key was found
- Option to ignore empty files
- Output results to the clipboard automatically
- Optionally output results to a file
Installation using PIP
To install promptify, simply run:
pip install code-promptify
Installation from Source
To install Promptify, follow these steps:
-
Clone the repository:
git clone https://github.com/vmehmeri/promptify.git cd promptify
-
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*"]
)--output
: File to write the output to (Optional. Output will be automatically written to a file calledoutput.promptify
if clipboard copy fails)--ignore-empty
: Flag to Ignore empty files (default: False)
Examples
-
Use default settings:
promptify
-
Include only Python and JavaScript files:
promptify --include "*.py" "*.js"
-
Exclude test files and ignore empty files:
promptify --exclude "*test*" --ignore-empty
-
Include all Python files except any inside a specific directory:
promptify --include "*.py" --exclude "*config/*"
Output
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
Built Distribution
File details
Details for the file code_promptify-0.6.0.tar.gz
.
File metadata
- Download URL: code_promptify-0.6.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f09364dc811a4202027266b9de8a14eca4a46d3ce25f08274b29f7d2bada3f2d |
|
MD5 | 7a3f3c2d30aa1a767e2efa02fa87b775 |
|
BLAKE2b-256 | cec4082411469dea53f31e800b19d6cd8f866b52902e0e51c3ab7cbef9590f20 |
File details
Details for the file code_promptify-0.6.0-py3-none-any.whl
.
File metadata
- Download URL: code_promptify-0.6.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5484c5cfc0ab142ebf0ebf66b588e7660f2e61c74d6e4b56961e5dd46a592549 |
|
MD5 | fd4e2f417f80c504bf32539e4a64c628 |
|
BLAKE2b-256 | b7d67daabd03a41dfdd20014f798f7e83900b99e7aef24669fab37385db74204 |