Gptize is a tool designed to concatenate the contents of project files for ChatGPT
Project description
GPTize
GPTize is a tool for merging the contents of project files into a single text document. It is specifically designed to create datasets that can be loaded into ChatGPT for analysis or training. I, Aleksei Svetlov, created this tool because I was tired of copying file contents and paths to make GPT understand the context of my project. With GPTize, this process is now automated and streamlined.
Features
- Exception handling for files based on
.gitignore
(including custom.gitignore-gptize
). - Support for specifying a target directory with repository root
.gitignore
. - Support for various encodings when reading files.
- Customizable output file naming based on the input file or directory name.
- Report generation including all processed files.
- Enhanced limit checks for file size and token count, with warnings logged instead of errors raised when limits are exceeded.
Installation
To install GPTize, simply use pip:
pip install gptize
This command will install GPTize and all its dependencies. After installation, you can use GPTize from the command line anywhere.
Usage
To run GPTize, you have several options:
Basic Usage
Simply invoke GPTize in the command line to process the current directory:
gptize
This will process all files in the current directory and generate a report with a default name like gptize-output-folder-YYYYMMDD-HHMMSS.txt
.
Specifying a Directory
To process a specific directory, use:
gptize /path/to/directory
This will process all files in the specified directory and create a report named gptize-output-folder-YYYYMMDD-HHMMSS.txt
.
Specifying a Single File
For processing a single file:
gptize /path/to/file.txt
This will process only the specified file and generate a report named gptize-output-file_name-YYYYMMDD-HHMMSS.txt
, where file_name
is the name of the input file.
Specifying Repository Root for .gitignore
If your .gitignore
is located in the root of the repository but you want to process files in a different subdirectory, you can use the --repo-root
option:
gptize /path/to/directory --repo-root /path/to/repo_root
This will apply the .gitignore
from the repository root to files in the specified directory.
Custom Output File
If you want to specify a custom output file name, use the -o
or --output
option:
gptize -o custom_output.txt
This command will override the default naming convention and use custom_output.txt
as the output file name.
Uploading to ChatGPT
After generating the merged file using GPTize, you can upload it to ChatGPT for improved context understanding. When making requests to ChatGPT, explicitly reference the uploaded file, for instance, using a phrase like ... based on the imported txt file.
This approach significantly enhances the quality of ChatGPT's responses by providing it with specific context.
Components
gptizer.py
: The main class for file processing.main.py
: The entry point of the application.models.py
: Data models for files and projects.output_builder.py
: Output constructor for report generation.settings.py
: Project settings.
Author and Maintainer
Aleksei Svetlov - Creator and main maintainer.
Contact Information
License
The project is distributed under the MIT License.
CHANGELOG
[0.3.0] - 2024-09-26
- [Feature] Support for specifying a target directory with repository root .gitignore
- Now
gptize
can be executed from any directory, while still applying.gitignore
rules from the root of the repository. - Added the
--repo-root
argument to specify the root directory of the repository where the.gitignore
is located. - Example usage:
gptize src/py_module/ --repo-root .
allows processing files insrc/py_module/
while applying.gitignore
rules from the repository root.
- Now
- [Feature] Added support for a custom .gitignore for GPTize
- Now, you can use an additional custom
.gitignore-gptize
file along with the repository root.gitignore
. - The custom
.gitignore-gptize
can be specified and will be applied in addition to the main.gitignore
. - Example usage:
gptize src/py_module/ --repo-root .
will apply both.gitignore
and.gitignore-gptize
.
- Now, you can use an additional custom
[0.2.5] - 2023-11-25
- [Modification] Updated File Size and Token Count Checks
- Modified the
combine_files
method ingptizer.py
to log a warning instead of raising an error when the total size of the combined content exceeds theMAX_FILE_SIZE_BYTES_LIMIT
orMAX_TOKEN_COUNT_LIMIT
defined insettings.py
.
- Modified the
[0.2.4] - 2023-11-16
- [Feature] Custom Output File Naming
- Output files now include the name of the processed file or directory, enhancing traceability and identification.
- [Enhancement] Settings Method for Custom File Names
- Updated the
Settings
class with a new method to generate output file names incorporating the name of the input file or directory.
- Updated the
- [Modification] Main File Processing Logic
- Modified
main.py
to adopt the new output file naming scheme.
- Modified
- [Fix] Minor Bug Fixes and Performance Improvements
- Addressed various minor bugs and optimized performance.
[0.2.3] - 2023-11-12
- [Enhancement] Detect binary files and handle errors gracefully
- Added binary file detection logic in load_file_content method.
- Improved error handling for file reading.
- Updated the OutputBuilder to handle binary files properly.
Project details
Release history Release notifications | RSS feed
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 gptize-0.3.2.tar.gz
.
File metadata
- Download URL: gptize-0.3.2.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8610425d01fcc248c99bef519d621852147818a83895f59afca4178677b73cc5 |
|
MD5 | 48f5d432b276ccb25f4de6f4af2c1a00 |
|
BLAKE2b-256 | 2fab03522468b557a39a798494eb2e6bb0a6353ad126905f4caedb9fa568655e |
File details
Details for the file gptize-0.3.2-py3-none-any.whl
.
File metadata
- Download URL: gptize-0.3.2-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca63ddca992b6a7e34d18998c6371f5b4605d5bdcc11b6a045cbb76cc37ed322 |
|
MD5 | 6bfe792d224f9ba3716e79b70564ec74 |
|
BLAKE2b-256 | 59b19822e663d2c74c87914ae5562f23dacbf803e11eae732f2dbd8c186a397f |