Skip to main content

Interactively explore a codebase with an LLM

Project description

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 or ollama. Default: openai
  -m MODEL, --model MODEL
                        The LLM model to use. Default: gpt-4o-mini for openai or mistral-nemo:latest for ollama

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.

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

explore_cli-0.3.2.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

explore_cli-0.3.2-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file explore_cli-0.3.2.tar.gz.

File metadata

  • Download URL: explore_cli-0.3.2.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.7 Darwin/23.5.0

File hashes

Hashes for explore_cli-0.3.2.tar.gz
Algorithm Hash digest
SHA256 5e9159e125c1aa4db4a62e291dcf1a8c9867efe96d1cc3a0ccf8e363ead4078d
MD5 d383ac17ddb7851d748e5525c80898e5
BLAKE2b-256 0696851afcab226ba37282acab0ab1d914e16873912733a1ddac55a6ed07b746

See more details on using hashes here.

File details

Details for the file explore_cli-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: explore_cli-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.7 Darwin/23.5.0

File hashes

Hashes for explore_cli-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dfbb4884916b87e98dc810cf0a42533240b7e57f6b9188e261df5bbecd40ab10
MD5 9fc41377363f50cd898f4e23732385a5
BLAKE2b-256 1cff1ab031a7ec60964f12a3d4cb365701ad836e21938b042dabbc4a318d05df

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