repo-gpt


Namerepo-gpt JSON
Version 0.1.6 PyPI version JSON
download
home_pagehttps://github.com/shruti222patel/repo-gpt
SummarySearch your code repository using GPT3.5 or GPT4.
upload_time2023-11-08 06:16:24
maintainer
docs_urlNone
authorShruti Patel
requires_python>=3.9,<3.12
licenseApache-2.0
keywords openai gpt repo repository search semantic-search query analyze-code gpt3 gpt3.5
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Repo GPT

Repo-GPT is a Python CLI tool designed to utilize the power of OpenAI's GPT-3 model. It facilitates the process of code analysis and search within your repositories.

![Repo-GPT in action](./imgs/example_output.png)

## Features

- Code extraction and processing from your repositories.
- Semantic search within your codebase through natural language queries.
- Response generation to natural language queries about your code.
- Specific file analysis within your codebase.

## Installation

Repo-GPT can be installed via [pip](https://pip.pypa.io/en/stable/):

```bash
brew install graphviz
pip install repo-gpt
```

Alternatively, you can clone and install from the source code:

```bash
git clone https://github.com/yourusername/repo-gpt.git
cd repo-gpt
poetry install
```

## Setting Up

Before starting, make sure to set up your OpenAI key in your environment variables.

```shell
export OPENAI_API_KEY=<insert your openai key>
```

To set up Repo-GPT, run the following command at the root of the project you want to search. This will create a `.repo_gpt` directory and store the code embeddings there:

```shell
repo-gpt setup
```

Repo-GPT will only add or update embeddings for new files or changed files. You can rerun the setup command as many times as needed.

## Usage

After setup, you can perform various tasks:

- **Semantic Search**: Find semantically similar code snippets in your codebase:

  ```shell
  repo-gpt search <text/question>
  ```

- **Codebase Query**: Ask questions about your codebase:

  ```shell
  repo-gpt query <text/question>
  ```

- **File Analysis**: Analyze a specific file:

  ```shell
  repo-gpt analyze <file_path>
  ```

- **Help**: Access the help guide:

  ```shell
  repo-gpt help
  ```

- **Generate tests**: Generate tests for a function:
Note: this assumes the function name is unique in the codebase, otherwise, it will pick the first function it finds with that name.

   ```shell
   repo-gpt add-test <unique function name> --test_save_file_path <absolute filepath to add tests to> --testing_package <testing package to use e.g. pytest>
   ```

Example:

```bash
repo-gpt setup --root_path ./my_project
repo-gpt search "extract handler"
repo-gpt query "What does the function `calculate_sum` do?"
repo-gpt analyze ./my_project/main.py
repo-gpt add-test function_name --test_save_file_path $PWD/test.py --testing_package pytest
```

## Contributing

We welcome your contributions! Before starting, please make sure to install Python `3.11` and the latest version of [poetry](https://python-poetry.org/docs/#installing-with-pipx). [Pyenv](https://github.com/pyenv/pyenv) is a convenient tool to manage multiple Python versions on your computer.

Here are the steps to set up your development environment:
0. Install global dependencies:

   ```shell
   nvm use --lts

   brew install graphviz
   export CFLAGS="-I $(brew --prefix graphviz)/include"
   export LDFLAGS="-L $(brew --prefix graphviz)/lib"
   pip install poetry
   ```

1. Export your OpenAI key to your environment variables:

   ```shell
   export OPENAI_API_KEY=<insert your openai key>
   ```

2. Install dependencies:

   ```shell
   poetry install --no-root
   jupyter lab build
   ```

3. Install pre-commit hooks:

   ```shell
   poetry run pre-commit install
   ```

4. Seed data:

   ```shell
   poetry run python cli.py setup
   ```

5. Query data:

   ```shell
   poetry run python cli.py search <text/question>
   ```

### Debugging

You can view the output of the `code_embeddings.pkl` using the following command:

```shell
poetry shell
python
import pandas as pd
pd.read_pickle('./.repo_gpt/code_embeddings.pkl', compression='infer')
```

#### Interpreter
```shell
poetry shell
ipython
%load_ext autoreload
%autoreload 2
```

## Roadmap

Here are the improvements we are currently considering:

- [X] Publishing to PyPi
- [X] Test suite addition
- [X] Add CI/CD
- [X] Prettify output
- [ ] Add readme section about how folks can contribute parsers for their own languages
- [ ] Save # of tokens each code snippet has so we can ensure we don't pass too many tokens to GPT
- [X] Add SQL file handler
- [ ] Add DBT file handler -- this may be a break in pattern as we'd want to use the manifest.json file
- [X] Create VSCode extension
- [ ] Ensure files can be added & deleted and the indexing picks up on the changes.
- [ ] Add .repogptignore file to config & use it in the indexing command
- [ ] Use pygments library for prettier code formatting

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/shruti222patel/repo-gpt",
    "name": "repo-gpt",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<3.12",
    "maintainer_email": "",
    "keywords": "openai,gpt,repo,repository,search,semantic-search,query,analyze-code,gpt3,gpt3.5",
    "author": "Shruti Patel",
    "author_email": "shruti222patel@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/19/36/946f489f6150714db4ae79ad97a8f359a44842ff1cbab973f58079aef7d4/repo_gpt-0.1.6.tar.gz",
    "platform": null,
    "description": "# Repo GPT\n\nRepo-GPT is a Python CLI tool designed to utilize the power of OpenAI's GPT-3 model. It facilitates the process of code analysis and search within your repositories.\n\n![Repo-GPT in action](./imgs/example_output.png)\n\n## Features\n\n- Code extraction and processing from your repositories.\n- Semantic search within your codebase through natural language queries.\n- Response generation to natural language queries about your code.\n- Specific file analysis within your codebase.\n\n## Installation\n\nRepo-GPT can be installed via [pip](https://pip.pypa.io/en/stable/):\n\n```bash\nbrew install graphviz\npip install repo-gpt\n```\n\nAlternatively, you can clone and install from the source code:\n\n```bash\ngit clone https://github.com/yourusername/repo-gpt.git\ncd repo-gpt\npoetry install\n```\n\n## Setting Up\n\nBefore starting, make sure to set up your OpenAI key in your environment variables.\n\n```shell\nexport OPENAI_API_KEY=<insert your openai key>\n```\n\nTo set up Repo-GPT, run the following command at the root of the project you want to search. This will create a `.repo_gpt` directory and store the code embeddings there:\n\n```shell\nrepo-gpt setup\n```\n\nRepo-GPT will only add or update embeddings for new files or changed files. You can rerun the setup command as many times as needed.\n\n## Usage\n\nAfter setup, you can perform various tasks:\n\n- **Semantic Search**: Find semantically similar code snippets in your codebase:\n\n  ```shell\n  repo-gpt search <text/question>\n  ```\n\n- **Codebase Query**: Ask questions about your codebase:\n\n  ```shell\n  repo-gpt query <text/question>\n  ```\n\n- **File Analysis**: Analyze a specific file:\n\n  ```shell\n  repo-gpt analyze <file_path>\n  ```\n\n- **Help**: Access the help guide:\n\n  ```shell\n  repo-gpt help\n  ```\n\n- **Generate tests**: Generate tests for a function:\nNote: this assumes the function name is unique in the codebase, otherwise, it will pick the first function it finds with that name.\n\n   ```shell\n   repo-gpt add-test <unique function name> --test_save_file_path <absolute filepath to add tests to> --testing_package <testing package to use e.g. pytest>\n   ```\n\nExample:\n\n```bash\nrepo-gpt setup --root_path ./my_project\nrepo-gpt search \"extract handler\"\nrepo-gpt query \"What does the function `calculate_sum` do?\"\nrepo-gpt analyze ./my_project/main.py\nrepo-gpt add-test function_name --test_save_file_path $PWD/test.py --testing_package pytest\n```\n\n## Contributing\n\nWe welcome your contributions! Before starting, please make sure to install Python `3.11` and the latest version of [poetry](https://python-poetry.org/docs/#installing-with-pipx). [Pyenv](https://github.com/pyenv/pyenv) is a convenient tool to manage multiple Python versions on your computer.\n\nHere are the steps to set up your development environment:\n0. Install global dependencies:\n\n   ```shell\n   nvm use --lts\n\n   brew install graphviz\n   export CFLAGS=\"-I $(brew --prefix graphviz)/include\"\n   export LDFLAGS=\"-L $(brew --prefix graphviz)/lib\"\n   pip install poetry\n   ```\n\n1. Export your OpenAI key to your environment variables:\n\n   ```shell\n   export OPENAI_API_KEY=<insert your openai key>\n   ```\n\n2. Install dependencies:\n\n   ```shell\n   poetry install --no-root\n   jupyter lab build\n   ```\n\n3. Install pre-commit hooks:\n\n   ```shell\n   poetry run pre-commit install\n   ```\n\n4. Seed data:\n\n   ```shell\n   poetry run python cli.py setup\n   ```\n\n5. Query data:\n\n   ```shell\n   poetry run python cli.py search <text/question>\n   ```\n\n### Debugging\n\nYou can view the output of the `code_embeddings.pkl` using the following command:\n\n```shell\npoetry shell\npython\nimport pandas as pd\npd.read_pickle('./.repo_gpt/code_embeddings.pkl', compression='infer')\n```\n\n#### Interpreter\n```shell\npoetry shell\nipython\n%load_ext autoreload\n%autoreload 2\n```\n\n## Roadmap\n\nHere are the improvements we are currently considering:\n\n- [X] Publishing to PyPi\n- [X] Test suite addition\n- [X] Add CI/CD\n- [X] Prettify output\n- [ ] Add readme section about how folks can contribute parsers for their own languages\n- [ ] Save # of tokens each code snippet has so we can ensure we don't pass too many tokens to GPT\n- [X] Add SQL file handler\n- [ ] Add DBT file handler -- this may be a break in pattern as we'd want to use the manifest.json file\n- [X] Create VSCode extension\n- [ ] Ensure files can be added & deleted and the indexing picks up on the changes.\n- [ ] Add .repogptignore file to config & use it in the indexing command\n- [ ] Use pygments library for prettier code formatting\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Search your code repository using GPT3.5 or GPT4.",
    "version": "0.1.6",
    "project_urls": {
        "Homepage": "https://github.com/shruti222patel/repo-gpt",
        "Repository": "https://github.com/shruti222patel/repo-gpt"
    },
    "split_keywords": [
        "openai",
        "gpt",
        "repo",
        "repository",
        "search",
        "semantic-search",
        "query",
        "analyze-code",
        "gpt3",
        "gpt3.5"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f828359cc31876a3ebf9e641c95216696b19ef671c132e6b1323fc8ae4a2bd21",
                "md5": "e33c4d6f1e3a4b57706d90c77beff170",
                "sha256": "61564724638f811a79760bedc0498c4e8c6efe13f4b7f1e462de860013bd226d"
            },
            "downloads": -1,
            "filename": "repo_gpt-0.1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e33c4d6f1e3a4b57706d90c77beff170",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<3.12",
            "size": 51099,
            "upload_time": "2023-11-08T06:16:23",
            "upload_time_iso_8601": "2023-11-08T06:16:23.150151Z",
            "url": "https://files.pythonhosted.org/packages/f8/28/359cc31876a3ebf9e641c95216696b19ef671c132e6b1323fc8ae4a2bd21/repo_gpt-0.1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1936946f489f6150714db4ae79ad97a8f359a44842ff1cbab973f58079aef7d4",
                "md5": "ff2f2eb95a9ed45404fa7e65f79f4c21",
                "sha256": "cc869493b4a87d54d1bcfe2d1cbf645e37612daeab50f27d557a28680bf289f0"
            },
            "downloads": -1,
            "filename": "repo_gpt-0.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "ff2f2eb95a9ed45404fa7e65f79f4c21",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<3.12",
            "size": 39170,
            "upload_time": "2023-11-08T06:16:24",
            "upload_time_iso_8601": "2023-11-08T06:16:24.793886Z",
            "url": "https://files.pythonhosted.org/packages/19/36/946f489f6150714db4ae79ad97a8f359a44842ff1cbab973f58079aef7d4/repo_gpt-0.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-08 06:16:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "shruti222patel",
    "github_project": "repo-gpt",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "repo-gpt"
}
        
Elapsed time: 0.52223s