Package: repo-gpt
Repo GPTRepo-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.FeaturesCode 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.InstallationRepo-GPT can be installed viapip:brewinstallgraphviz
pipinstallrepo-gptAlternatively, you can clone and install from the source code:gitclonehttps://github.com/yourusername/repo-gpt.gitcdrepo-gpt
poetryinstallSetting UpBefore starting, make sure to set up your OpenAI key in your environment variables.exportOPENAI_API_KEY=<insertyouropenaikey>To set up Repo-GPT, run the following command at the root of the project you want to search. This will create a.repo_gptdirectory and store the code embeddings there:repo-gptsetupRepo-GPT will only add or update embeddings for new files or changed files. You can rerun the setup command as many times as needed.UsageAfter setup, you can perform various tasks:Semantic Search: Find semantically similar code snippets in your codebase:repo-gptsearch<text/question>Codebase Query: Ask questions about your codebase:repo-gptquery<text/question>File Analysis: Analyze a specific file:repo-gptanalyze<file_path>Help: Access the help guide:repo-gpthelpGenerate 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.repo-gptadd-test<uniquefunctionname>--test_save_file_path<absolutefilepathtoaddteststo>--testing_package<testingpackagetousee.g.pytest>Example:repo-gptsetup--root_path./my_project
repo-gptsearch"extract handler"repo-gptquery"What does the function `calculate_sum` do?"repo-gptanalyze./my_project/main.py
repo-gptadd-testfunction_name--test_save_file_path$PWD/test.py--testing_packagepytestContributingWe welcome your contributions! Before starting, please make sure to install Python3.11and the latest version ofpoetry.Pyenvis 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:nvmuse--lts

brewinstallgraphvizexportCFLAGS="-I$(brew--prefixgraphviz)/include"exportLDFLAGS="-L$(brew--prefixgraphviz)/lib"pipinstallpoetryExport your OpenAI key to your environment variables:exportOPENAI_API_KEY=<insertyouropenaikey>Install dependencies:poetryinstall--no-root
jupyterlabbuildInstall pre-commit hooks:poetryrunpre-commitinstallSeed data:poetryrunpythoncli.pysetupQuery data:poetryrunpythoncli.pysearch<text/question>DebuggingYou can view the output of thecode_embeddings.pklusing the following command:poetryshell
python
importpandasaspd
pd.read_pickle('./.repo_gpt/code_embeddings.pkl',compression='infer')Interpreterpoetryshell
ipython
%load_extautoreload
%autoreload2RoadmapHere are the improvements we are currently considering:Publishing to PyPiTest suite additionAdd CI/CDPrettify outputAdd readme section about how folks can contribute parsers for their own languagesSave # of tokens each code snippet has so we can ensure we don't pass too many tokens to GPTAdd SQL file handlerAdd DBT file handler -- this may be a break in pattern as we'd want to use the manifest.json fileCreate VSCode extensionEnsure files can be added & deleted and the indexing picks up on the changes.Add .repogptignore file to config & use it in the indexing commandUse pygments library for prettier code formatting