Skip to main content

Search your code repository using GPT3.5 or GPT4.

Project description

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

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:

pip install repo-gpt

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

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.

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:

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:

    repo-gpt search <text/question>
    
  • Codebase Query: Ask questions about your codebase:

    repo-gpt query <text/question>
    
  • File Analysis: Analyze a specific file:

    repo-gpt analyze <file_path>
    
  • Help: Access the help guide:

    repo-gpt help
    

Example:

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

Contributing

We welcome your contributions! Before starting, please make sure to install Python 3.11 and the latest version of poetry. Pyenv is a convenient tool to manage multiple Python versions on your computer.

Here are the steps to set up your development environment:

  1. Export your OpenAI key to your environment variables:

    export OPENAI_API_KEY=<insert your openai key>
    
  2. Install dependencies:

    poetry install --no-root
    
  3. Install pre-commit hooks:

    poetry run pre-commit install
    
  4. Seed data:

    poetry run python cli.py setup
    
  5. Query data:

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

Debugging

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

pd.read_pickle('./.repo_gpt/code_embeddings.pkl', compression='infer')

Roadmap

Here are the improvements we are currently considering:

  • Publishing to PyPi
  • Test suite addition
  • Add CI/CD
  • 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
  • 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

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

repo_gpt-0.1.0.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

repo_gpt-0.1.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file repo_gpt-0.1.0.tar.gz.

File metadata

  • Download URL: repo_gpt-0.1.0.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1039-azure

File hashes

Hashes for repo_gpt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d95bece634e7313627832ee3d0ddf3297b88788af175a1f7ed3b1876677f3afa
MD5 0b6ac5becbd68b4bcd2b3ac5667daa72
BLAKE2b-256 3175923f5269a367c80edd39f8e833b01b106845a88e693427c12bfa8aa6573a

See more details on using hashes here.

File details

Details for the file repo_gpt-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: repo_gpt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1039-azure

File hashes

Hashes for repo_gpt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e0c1af1ceeef026e26d7925487378e034ee89f3043b98a39be53b94d059bd60
MD5 a142413e5d1e5b76c0a7661ff6ac5a13
BLAKE2b-256 857507ffcf557df576cb3185840deeeb130a8a0087bf09e271816d7dc7b4bd07

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page