A tool to turn a Git repository into an LLM-friendly prompt
Project description
git2string
git2string is a powerful tool that simplifies the process of converting an entire Git repository into a single LLM-friendly text file, which is easy to upload. It also tells you how many tokens the text file will consume. So, it will hopefully be saving you a lot of time and effort.
It will automatically ignore all binary files. Additionally, it will respect your .gitignore. You can also create a .r2pignore file in your repo to specify the files that should be skipped for prompt generation.
Installation
pip3 install git2string
Usage
git2string <url of repository>
For example:
git2string https://github.com/mozilla/experimenter
The output would look like this:
ℹ Cloning repository to ./tmpohen963u
✔ Using tokenizer for model gpt2
Concatenating: 100%|██████████████████████| 3331/3331 [00:00<00:00, 7547.49it/s]
✔ All valid files have been concatenated into llm_prompt.txt
ℹ 21334492 tokens are present in the prompt
If you have cloned your desired repository already, you can just specify its path.
git2string <repo root directory>
By default, the prompt will be generated in a file called llm_prompt.txt. You can specify a different filename as follows:
git2string <repo root directory> --output-file <filename>
This tool uses OpenAI's tiktoken to count the number of tokens in the generated prompt. By default, gpt2's tokenizer will be used. But you can count tokens for most OpenAI models.
git2string <repo root directory> --openai-model <model name>
For example:
git2string /tmp/myrepo --openai-model gpt-4o
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 git2string-0.1.5.tar.gz
.
File metadata
- Download URL: git2string-0.1.5.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f5f83aad0122100408b0b19ada4350369bd665f9a23c901ca013196d57d2a9d |
|
MD5 | b793b2de58f75a2145fc87e604c08a56 |
|
BLAKE2b-256 | 6e4e035c58eed29e0f10dad90342f0bf236b76e8fc148623c287df9e382dbd82 |
File details
Details for the file git2string-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: git2string-0.1.5-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82713a7adf14e3744fe6d6766b0f93dce9911e52d06adf0cfb93abafa323c3cd |
|
MD5 | b942045f8f33590510f35f5f225813a0 |
|
BLAKE2b-256 | 6ce40f102f6e12620db8032b3c98c7df1144d46b308acdec41cdef52ad9a0500 |