Skip to main content

Convert code repos into an LLM prompt-friendly format. Forked from https://github.com/zackees/gptrepo

Project description

gptify

gptify is a command-line tool that transforms a Git repository into a single text file or multiple text chunks suitable for use with Large Language Models (LLMs) like ChatGPT. It preserves the file structure and content, enabling LLMs to understand and process the codebase for tasks such as code review, documentation generation, and answering questions about the code. This project is a fork of gptrepo with added features.

Relevance

This tool addresses the challenge of effectively using LLMs with codebases. By converting a repository into a digestible format, gptify allows developers to leverage the power of LLMs for various development tasks. It simplifies the process of feeding code context into LLMs, avoiding size limitations and formatting issues.

Installation

The easiest way to install gptify is using pip:

pip install gptify

Alternatively, you can install it using pipx:

poetry build && pipx install dist/*.whl

You can also uninstall older versions using the provided install script:

./install.sh

Usage

  1. Navigate to the root directory of your Git repository.
  2. Run the gptify command:
gptify

This will generate a file named gptify_output.txt in the current directory containing the formatted repository content. You can then copy and paste the contents of this file into a ChatGPT session.

Options

  • --output <filename>: Specifies the name of the output file (default: gptify_output.txt).
  • --clipboard: Copies the output directly to the clipboard instead of creating an output file.
  • --openfile: Opens the output file after creation using the default system application.
  • --preamble <filepath>: Prepends a custom preamble to the output file. This is useful for providing instructions or context to the LLM.
  • --chunk: Enables chunking of the output into smaller files, useful for handling large repositories that exceed LLM context limits. Used with --max_tokens and --overlap.
  • --max_tokens: Sets the maximum number of tokens per chunk when using the --chunk option (default: 900000). Requires the tiktoken library.
  • --overlap: Sets the number of overlapping tokens between chunks when using the --chunk option (default: 400). Helps maintain context across chunks. Requires the tiktoken library.
  • --output_dir: Specifies the output directory for chunks when using --chunk (default: gptify_output_chunks).

Example with custom output file and preamble:

gptify --output my_repo.txt --preamble instructions.txt

This command will generate my_repo.txt with the processed repository data, prepended with the content of instructions.txt.

Example with chunking:

gptify --chunk --max_tokens 4000 --overlap 200

This will create multiple files in the gptify_output_chunks directory, each containing a chunk of the repository data, with a maximum of 4000 tokens and an overlap of 200 tokens.

Contributing

Contributions are welcome.

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

gptify-0.5.0b0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

gptify-0.5.0b0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file gptify-0.5.0b0.tar.gz.

File metadata

  • Download URL: gptify-0.5.0b0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for gptify-0.5.0b0.tar.gz
Algorithm Hash digest
SHA256 cd39d2cf3320f38da62d7f2249b521838dd4caf1239788e2b69f229aab1ceeac
MD5 2ca7e6fcea79e3ec19a79f162d78d1e1
BLAKE2b-256 6ab7392eeff099bc92c9668cc3224bb2dcedc13c2bb28fe030907233b7e2b2aa

See more details on using hashes here.

File details

Details for the file gptify-0.5.0b0-py3-none-any.whl.

File metadata

  • Download URL: gptify-0.5.0b0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for gptify-0.5.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 c6805ae28c74f25699c9ee100448eb509fca4dc83305bf9fe0e3d25a962d6576
MD5 79f1eca141ac56d50814d0c3fa163232
BLAKE2b-256 bcd1520d59b53ca303a323e817d8312085631b6df6d08c1ee40944d255a75397

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