Skip to main content

Semantic search for functions in Python codebases

Project description

Codevec

Codevec is a user-friendly semantic search tool for Python codebases.

License: Apache 2.0

pip install codevec

Overview

Codevec is a semantic search tool for Python codebases that lets you find functions using plain English queries—no need to know exact function names or keywords to grep.

It runs entirely on lightweight local models, so indexing and searching a codebase take only seconds. Being entirely local, your code never leaves your machine: no API calls, no usage limits.

Unlike general-purpose AI assistants, Codevec is purpose-built for code search. It focuses on quickly pinpointing relevant function definitions without verbose explanations, making it especially effective for navigating large or unfamiliar repositories.

Note: Codevec currently indexes Python functions only. Module-level code is not indexed.

Quick Start

1. Index your codebase

vec-index ./your/project/filepath

Note: Re-index after making significant changes to your codebase!

2. Search with natural language

Search from a terminal within the indexed codebase:

vec-search email validation

Search from a different directory:

vec-search "authentication logic" --repo ./your/project/filepath

3. results

(.venv) user@Computer demo-repo % vec-search email validation
Initializing search system...
Found 5 results

================================================================================

┌─ Result #1 ───────────────────────────────────────────────────────────
│ Similarity: 49.3%  │  Rerank: -2.527
├───────────────────────────────────────────────────────────────────────────────
│ 📁 File: /Users/user/development/project/utils/validation.py
│ ⚙️ Function: validate_email (line 5)
├───────────────────────────────────────────────────────────────────────────────
│ Code:
│    5 │ def validate_email(email):
│    6 │     """Check if email address is in valid format"""
│    7 │     pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
│    8 │     return re.match(pattern, email) is not None
└───────────────────────────────────────────────────────────────────────────────

Note: The filepath is clickable in VS Code terminals!

Advanced Usage: Model server

Run the model server to keep models loaded in memory for faster searches:

vec-server  # Starts server on localhost:8000
            # Codevec will automatically use the server when available

How It Works

Indexing & Embedding — Codevec walks your codebase, and uses AST parsing to discover Python functions, then uses a lightweight local transformer to generate embeddings

ChromaDB Storage — Embeddings are stored in a ChromaDB collection located at .codevec/ in your project root

Searching — Queries are embedded and matched against ChromaDB using semantic similarity, then results are reranked using a cross-encoder for improved relevance

Re-indexing — Simply run vec-index again on the same directory to update the index with new or modified functions

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

codevec-1.0.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codevec-1.0.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file codevec-1.0.0.tar.gz.

File metadata

  • Download URL: codevec-1.0.0.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for codevec-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d7a32dd28bb958fdabdf54c350b8ca55cf986883ccd4a54ebff2a611e9e5f497
MD5 642bdfeffcacee3edc9d7d12507902ad
BLAKE2b-256 cc976c2e58446511d3a04ee2a1f2a02ec8cc3e7ece4111a59495627d9f206c86

See more details on using hashes here.

File details

Details for the file codevec-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: codevec-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for codevec-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 56d8b6ae012675cc59b798c223debff03682941b1720f2a380db5f92f2568630
MD5 2e743e102ad7ef2350d809877eb4ec2f
BLAKE2b-256 1bb50405ffd027b846ee921a2d7132450d2f2afe3f8df9dce23291f5d322325e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page