git2string


Namegit2string JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/hathibelagal-dev/git2string
SummaryA tool to turn a Git repository into an LLM-friendly prompt
upload_time2025-02-19 03:34:48
maintainerNone
docs_urlNone
authorAshraff Hathibelagal
requires_python>=3.6
licenseNone
keywords ai language-models devtools gpt-4 openai llama mistral gemini chatbot
VCS
bugtrack_url
requirements tqdm black tiktoken rich pathspec build gitpython twine
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # git2string
![PyPI - Version](https://img.shields.io/pypi/v/git2string) ![PyPI - License](https://img.shields.io/pypi/l/git2string)

git2string is a powerful tool that can quickly convert an entire Git repository to a prompt that can be fed to any large language model (LLM).

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
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hathibelagal-dev/git2string",
    "name": "git2string",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "ai language-models devtools gpt-4 openai llama mistral gemini chatbot",
    "author": "Ashraff Hathibelagal",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/19/79/4b9f9614143883b1d6f69bc1f2cae7324de99cba96c73760ec755e61e20a/git2string-0.1.3.tar.gz",
    "platform": null,
    "description": "# git2string\n![PyPI - Version](https://img.shields.io/pypi/v/git2string) ![PyPI - License](https://img.shields.io/pypi/l/git2string)\n\ngit2string is a powerful tool that can quickly convert an entire Git repository to a prompt that can be fed to any large language model (LLM).\n\nIt 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.\n\n## Installation\n\n```\npip3 install git2string\n```\n\n## Usage\n\n```\ngit2string <url of repository>\n```\n\nFor example:\n\n```\ngit2string https://github.com/mozilla/experimenter\n```\n\nThe output would look like this:\n\n```\n\u2139 Cloning repository to ./tmpohen963u\n\u2714 Using tokenizer for model gpt2\nConcatenating: 100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 3331/3331 [00:00<00:00, 7547.49it/s]\n\u2714 All valid files have been concatenated into llm_prompt.txt\n\u2139 21334492 tokens are present in the prompt\n```\n\nIf you have cloned your desired repository already, you can just specify its path.\n\n```\ngit2string <repo root directory>\n```\n\nBy default, the prompt will be generated in a file called **llm_prompt.txt**. You can specify a different filename as follows:\n\n```\ngit2string <repo root directory> --output-file <filename>\n```\n\nThis 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.\n\n```\ngit2string <repo root directory> --openai-model <model name>\n```\n\nFor example:\n\n```\ngit2string /tmp/myrepo --openai-model gpt-4o\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A tool to turn a Git repository into an LLM-friendly prompt",
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://github.com/hathibelagal-dev/git2string",
        "Source": "https://github.com/hathibelagal-dev/git2string",
        "Tracker": "https://github.com/hathibelagal-dev/git2string/issues"
    },
    "split_keywords": [
        "ai",
        "language-models",
        "devtools",
        "gpt-4",
        "openai",
        "llama",
        "mistral",
        "gemini",
        "chatbot"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "bd4e167595b60588cd06f0690c167053725979ad089fdb914691efc9fed8e94d",
                "md5": "e8850a3283d71b9deb40618bbc566d9e",
                "sha256": "3bc4f46022987c0b267dcb6d4fc2618e7a105bde93cbedb864f94a6ee037248b"
            },
            "downloads": -1,
            "filename": "git2string-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e8850a3283d71b9deb40618bbc566d9e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 11242,
            "upload_time": "2025-02-19T03:34:46",
            "upload_time_iso_8601": "2025-02-19T03:34:46.945037Z",
            "url": "https://files.pythonhosted.org/packages/bd/4e/167595b60588cd06f0690c167053725979ad089fdb914691efc9fed8e94d/git2string-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "19794b9f9614143883b1d6f69bc1f2cae7324de99cba96c73760ec755e61e20a",
                "md5": "ff3e2979d6c47679576e4c59747b733a",
                "sha256": "4d659ad7a254b442d165c30737db48d4651d1cbefecc1d4cea524e67ef164e95"
            },
            "downloads": -1,
            "filename": "git2string-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "ff3e2979d6c47679576e4c59747b733a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 10084,
            "upload_time": "2025-02-19T03:34:48",
            "upload_time_iso_8601": "2025-02-19T03:34:48.084811Z",
            "url": "https://files.pythonhosted.org/packages/19/79/4b9f9614143883b1d6f69bc1f2cae7324de99cba96c73760ec755e61e20a/git2string-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-19 03:34:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hathibelagal-dev",
    "github_project": "git2string",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "tqdm",
            "specs": []
        },
        {
            "name": "black",
            "specs": []
        },
        {
            "name": "tiktoken",
            "specs": []
        },
        {
            "name": "rich",
            "specs": []
        },
        {
            "name": "pathspec",
            "specs": []
        },
        {
            "name": "build",
            "specs": []
        },
        {
            "name": "gitpython",
            "specs": []
        },
        {
            "name": "twine",
            "specs": []
        }
    ],
    "lcname": "git2string"
}
        
Elapsed time: 1.52788s