Op

Open-source code search with OpenAI's function calling

Hacker News

Open-source code search with OpenAI's function calling

We're excited to share a tool we've been working on called gpt-code-search. It allows you to search any codebase using natural language locally on your machine. We leverage OpenAI's GPT-4 and function calling to retrieve, search, and answer queries about your code. All you need to do is to install the package with `pip install gpt-code-search`, set up your `OPENAI_API_KEY` as an environment variable, and start asking questions with `gpt-code-search query <your question>`. E.g. You can ask questions like "How do I use the analytics module?" or "Document all the API routes related to authentication." This is still early and hacked together in the past week, but we wanted to get it out there and get feedback. We utilize OpenAI's function calling to let GPT-4 call certain predefined functions in our library. You do not need to implement any of these functions yourself. These functions are designed to interact with your codebase and return enough context for the LLM to perform code searches without pre-indexing it or uploading your repo to a third party other than OpenAI. So, you only need to run the tool from the directory you want to search. The functions currently available for the LLM to call are: `search_codebase` - searches the codebase using a TF-IDF vectorizer `get_file_tree` - provides the file tree of the codebase `get_file_contents` - provides the contents of a file These functions are implemented in `gpt-code-search` and are triggered by chat completions. The LLM is prompted to utilize the search_codebase and get_file_tree function as needed to find the necessary context to answer your query and then loops as needed to collect more context with the get_file_contents until the LLM responds. A couple of limitations of this approach, GPT cannot load context across multiple files in a single prompt since we are passing in the contents of a single file in each function call. So, GPT repeatedly calls the get_file_contents function to load context from multiple files. This increases the latency and cost of the tool. Another thing we realized as we were building is that the level of search and retrieval is limited by the context window, which refers to the scope of the search conducted by the tool, meaning that we can only search five levels deep in the file system and can only pass in the contents of one file at a time. So it would be best to run the tool from the package/directory closest to the code you want to search. We plan to add support for local vector embeddings to improve search and retrieval. Combining the vector embeddings with function calling should result in much faster and higher quality results. Also, support for other models, chat interactions in the command line, and generating code is already on our backlog! Please check out gpt-code-search and let me know your thoughts, feedback, or suggestions.

Share card

Actual performance

19points
7comments
Made the leaderboard

Launch Intel predictions

Analyze your own launch →
Product HuntOn track for Day 1 leaderboard · Strong signals: mac, model, models · Missing: agents, macos, agent
96%96% predicted probability of success on Product Hunt, based on ML models trained on real launch data.
best fitHighest predicted score across all platforms for this description.
Indie HackersFits the IH revenue-focused audience · Missing: supports, reddit linkedin, podcasting
85%85% predicted probability of success on Indie Hackers, based on ML models trained on real launch data.
Hacker NewsStrong engagement from HN community · Strong signals: excited, ide, io · Missing: https docs, just released, exist
59%59% predicted probability of success on Hacker News, based on ML models trained on real launch data.
nativeThis product was originally launched on this platform.
TrustMRRFits verified-revenue profile · Missing: mobile apps, ios, personal
52%52% predicted probability of success on TrustMRR, based on ML models trained on real launch data.
AppSumoMay struggle as an AppSumo deal · Strong signals: calls · Missing: plus, platform, intuitive
39%39% predicted probability of success on AppSumo, based on ML models trained on real launch data.
Acquire.comPre-revenue stage for this audience · Missing: arr, mrr, revenue
10%10% predicted probability of success on Acquire.com, based on ML models trained on real launch data.
BetaListMay not resonate with beta-testers · Strong signals: chat · Missing: web3, crypto, cryptocurrency
0%0% predicted probability of success on BetaList, based on ML models trained on real launch data.

Correct prediction on native model

Similar products

An
An open-source alternative to OpenAI function calling70%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

An open-source alternative to OpenAI function calling

Hacker News4
Pl
Playground for OpenAI Function Calling50%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Playground for OpenAI Function Calling

Hacker News5
Pl
Playground for OpenAI Function Calling62%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Playground for OpenAI Function Calling

Hacker News51
Ea
Easily generate OpenAI function calling schemas from classes in Java34%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Easily generate OpenAI function calling schemas from classes in Java

Hacker News2
Op
Open-Source Function Calling (Anthropic, or Any LLM)57%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Open-Source Function Calling (Anthropic, or Any LLM)

Hacker News2
ty
typerassistant – turn any Typer app in to a function-calling assistant45%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

typerassistant – turn any Typer app in to a function-calling assistant

Hacker News1
Fu
Func Runner – Managed Function Calling for OpenAI Assistants56%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Func Runner – Managed Function Calling for OpenAI Assistants

Hacker News2
Fl
FlowTest – Drag and Drop GUI for OpenAI Function Calling56%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

FlowTest – Drag and Drop GUI for OpenAI Function Calling

Hacker News1
An
An open-source API built on top of OpenAI Embeddings and Pinecone79%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

An open-source API built on top of OpenAI Embeddings and Pinecone

Hacker News5
Fu
Function calling on Claude 2 and Cohere with good DX powered by Cursive39%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Function calling on Claude 2 and Cohere with good DX powered by Cursive

Hacker News1