Skip to content

pa-vector-add

by rob

Data

Add documents to a ChromaDB vector collection with embeddings. Reads JSON input with id, content, and metadata fields, uses pa-embed tool to obtain embeddings, and stores the document in the specified ChromaDB collection.

# pa-vector-add

Add documents to a ChromaDB vector collection with embeddings. Reads JSON input with id, content, and metadata fields, generates embeddings using pa-embed tool, and stores the document in the specified ChromaDB collection.

## Installation

This is a CmdForge tool. It should be installed and available in your PATH after CmdForge setup. Use it via pipe for input.

## Usage

```bash
# Add a document to the default collection
echo '{"id": "doc1", "content": "This is my document text", "metadata": {"source": "cli"}}' | pa-vector-add --path ~/.pa2/data/chromadb

# Add to a custom collection
echo '{"id": "note1", "content": "Meeting notes from today", "metadata": {"date": "2026-02-12"}}' | pa-vector-add --path /path/to/chromadb --collection notes

# Use a different embedding model
echo '{"id": "doc2", "content": "Another document", "metadata": {}}' | pa-vector-add --path ~/.pa2/data/chromadb --embed-model all-minilm
```

## Arguments

| Flag | Default | Description |
|------|---------|-------------|
| `--path` | *(required)* | ChromaDB persist directory |
| `--collection` | `memories` | Collection name |
| `--embed-model` | `nomic-embed-text` | Ollama model for embeddings |

## Input Format

The tool expects JSON input via stdin with the following structure:

```json
{
  "id": "unique-document-id",
  "content": "The text content to embed and store",
  "metadata": {
    "key": "value"
  }
}
```

## How It Works

1. **parse_and_validate**: Parses the JSON input from stdin and validates that required fields (id, content) are present
2. **generate_embedding**: Calls the `pa-embed` tool to generate vector embeddings for the document content using the specified Ollama model
3. **add_to_chromadb**: Stores the document, its embedding, and metadata in the specified ChromaDB collection

## Dependencies

- **pa-embed**: Used to generate embeddings via Ollama

No reviews yet.

Issues

No issues reported for this tool.