tramai-vectorstore-chroma
Version: 0.6.0
Status: Preview (published)
Role: ChromaDB implementation of the vector store SPI.
Purpose
This module provides a concrete implementation of VectorStore that talks to a ChromaDB server over its HTTP API. It upserts vectors into named collections and runs similarity searches against them. Failures surface as ChromaException.
Dependencies
// build.gradle.kts
dependencies {
implementation(platform("dev.tramai:tramai-bom:0.6.0"))
implementation("dev.tramai:tramai-vectorstore-chroma")
}
Quick Start
import dev.tramai.embedding.OpenAiEmbeddingModel
import dev.tramai.vectorstore.SearchResult
import dev.tramai.vectorstore.VectorEntry
import dev.tramai.vectorstore.chroma.ChromaVectorStore
val embeddings = OpenAiEmbeddingModel(apiKey = System.getenv("OPENAI_API_KEY"))
val store = ChromaVectorStore(baseUrl = "http://localhost:8000")
// Upsert into a collection (created on first write)
val text = "Chroma is a vector database."
store.upsert(
collection = "my-docs",
vectors = listOf(
VectorEntry(
id = "doc-1",
vector = embeddings.embed(text),
content = text,
metadata = mapOf("source" to "handbook"),
),
),
)
// Search
val results: List<SearchResult> = store.search(
collection = "my-docs",
query = embeddings.embed("What is Chroma?"),
topK = 3,
)
results.forEach { println("${it.score} ${it.content}") }
When to use this module
- You are using ChromaDB as your vector store.
- You want a fast, local, file-backed vector database for development.
When NOT to use this module
- You are using a different vector database like Postgres with pgvector.
