Skip to main content

explore

Interactively explore a codebase with an LLM

PyPI - Version

explore is a script to interactively explore a codebase by chatting with an LLM. It uses retrieval-augmented generation via chromadb to provide the LLM with relevant source code from the codebase.

explore uses OpenAI models by default, so you'll need an OpenAI API key.

Installation

explore is available on PyPI. I recommend installing it with pipx:

pipx install explore-cli
export OPENAI_API_KEY=<your OpenAI API key>
explore <directory>

Alternatively, you can clone this repository and run the script with poetry:

poetry install
poetry build
export OPENAI_API_KEY=<your OpenAI API key>
poetry run explore <directory>

Usage

usage: explore [-h] [-l LLM] [-m MODEL] directory

Interactively explore a codebase with an LLM.

positional arguments:
  directory             The directory to index and explore.

options:
  -h, --help            show this help message and exit
  -l LLM, --llm LLM     The LLM backend, one of openai, ollama, or azure. Default: openai. If using Azure, make sure to
                        set the AZURE_OPENAI_ENDPOINT and OPENAI_API_VERSION environment variables.
  -m MODEL, --model MODEL
                        The LLM model to use. Default: gpt-4o-mini for openai, mistral-nemo:latest for ollama, or
                        gpt-4o for azure.

How it works

  1. The codebase is indexed into a local Chroma store. Each file is split into chunks using language-specific separators.
  2. Documents relevant to the query are collected using multiple retrieval strategies:
    • Primary retrieval is done through vector similarity using the indexed embeddings.
    • A multi-query retriever issues multiple variations of the query to increase the diversity and relevance of retrieved documents.
    • Additionally, a history-aware retriever reformulates the user query, considering the conversation history to better capture context.
  3. Retrieved documents are deduplicated, concatenated, and added as context to the LLM, which generates an answer to the user's question. Answers include specific references to the files and code pertinent to the query.

Using Azure OpenAI

explore can connect to an Azure OpenAI instance using Azure Active Directory authentication. First, set the relevant environment variables (you can find the values to use for these in the Azure portal):

export AZURE_OPENAI_ENDPOINT=https://your-resource-name.openai.azure.com # <- endpoint for the Azure OpenAI instance
export OPENAI_API_VERSION=2024-10-01-preview # <- API version for the deployment you want to use

Make sure you are authenticated via the Azure CLI:

az login

When you invoke explore, pass the Azure OpenAI deployment name as the --model argument and specify azure as the --llm:

explore --llm azure --model gpt-4o /some/directory

Metadata

Release files for explore-cli 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for explore-cli 0.4.1
File Size Uploaded Provenance Actions
explore_cli-0.4.1.tar.gz 109.9 kB Without provenance Details for explore_cli-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for explore-cli 0.4.1
File Interpreter ABI Platform Actions
explore_cli-0.4.1-py3-none-any.whl Python 3 none any Details for explore_cli-0.4.1-py3-none-any.whl

Total release size: 117.7 kB

Release files / explore_cli-0.4.1.tar.gz

Download URL explore_cli-0.4.1.tar.gz
Size 109.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6d2905e30b2d4525f04f621ca1ef3b2f997c598715c00943935f954070b84bb6
BLAKE2b-256 checksum
How to use checksums
5f2671921946a1bdd848ad225da92d896e93d191372b6ec8d7ba1a380fcab630
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.13

Release files / explore_cli-0.4.1-py3-none-any.whl

Download URL explore_cli-0.4.1-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
105e06ecbbdd03878ad47d6e08868335a66f0ec38a605073087448f1e7d80845
BLAKE2b-256 checksum
How to use checksums
a3bee6c2e2fa627af99137858728efa38babeb37231b2a2015835f41aefbcc73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.13

Security for explore-cli 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page