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: Reindex 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

Reindexing — 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.3.tar.gz (15.9 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.3-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: codevec-1.0.3.tar.gz
  • Upload date:
  • Size: 15.9 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.3.tar.gz
Algorithm Hash digest
SHA256 59e935f0594b950dc2d6688d3551e8aaa798edcd12d719bf5fcbe851683fef1b
MD5 53a70b3db2d203c7d396575a91c7e7ef
BLAKE2b-256 0817a891b8c34c16d62d9c12a79952aa1a913c49fe4d4c77991b616ad17d6e10

See more details on using hashes here.

File details

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

File metadata

  • Download URL: codevec-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 16.5 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 679f89e3f23378f19c60c547189fafbef0ea4b29f3c5f3adf708a4b0a5024557
MD5 244af7b10eeb7c1cda3391ffb4a0dc71
BLAKE2b-256 7c48ac3f8091628aa8804a0c5d76ac9d5fc2bdf8c1a90a5eb091a72a01335ef5

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