SuperAPI AI Directory

gpt-code-search

search a codebase with natural language using AI

Open website

About this tool

gpt-code-search (also called gpt-code-assistant within the project) is an AI-based open-source tool for exploring, querying, and understanding arbitrary codebases. It leverages language models (LLMs) and vector embeddings (a technique for converting objects such as text into vectors) to enable natural language search.

Purpose

The tool is designed to solve the problem of developers needing to understand, debug, or query a codebase without having to manually copy and paste code snippets into prompts, and without having to send code to third-party services other than OpenAI. It lets models such as GPT-4 determine the most relevant code snippets in the codebase on their own, and allows queries to be completed in the terminal without a separate UI.

Main capabilities

  • LLM-based search and retrieval: Use language models for efficient code search, retrieval, and understanding.
  • File system integration: Designed to work with arbitrary codebases, directly operating on local code and seamlessly fitting into existing workflows.
  • Language agnostic: Supports multiple programming languages.
  • Privacy-centered design: Code snippets are transmitted only when a question is asked and the language model requests relevant code (note: code snippets are shared with OpenAI).
  • Future plans include support for local models and the ability to generate code.

Usage

First create a project to index all files; this step creates embeddings for each file and stores them in a local database.

The query command can be used to query the codebase.

If you want to generate tests for a specific file (for example, analytics.py), mention the file name to improve accuracy.

For general usage questions about a module (such as analytics), use keywords to search within the codebase.

Note: Mentioning file names or specific keywords can improve search accuracy.

Get a list of all projects.

Reindex a project and update embeddings to the latest content.

Delete a project and all of its data (including embeddings).

Optionally choose the model used for queries; the default is gpt-3.5-turbo-16k. The selected model is stored in $HOME/.gpt-code-assistant/config.toml.

If it has not been configured yet, the tool will prompt you to configure OPENAI_API_KEY.

Use cases

  • Help debug errors and find related code and files
  • Document large files or features in markdown format
  • Generate new code based on existing files and conventions
  • Ask general questions about any part of the codebase

Limitations and future plans

Currently, code snippets are shared with OpenAI. Future plansinclude: using vector embeddings to improve search and retrieval; adding support for other models (Claude, Bedrock, etc.); adding support for local models (Llama2, Starcoder, etc.); adding support for generating code and saving it to files; supporting search across multiple codebases; allowing the model to create new executable functions; using guidance to improve prompts.

Other information

This project uses the Apache 2.0 license. Community contributions are welcome; you can fork the repository and submit a pull request. If you encounter problems during use, you can open an issue on GitHub or contact narenkmanoharan@gmail.com directly.