🎉 ai-infra v1.0 is here — Production-ready AI/LLM infrastructure
What's new
nfrax logonfrax

Infrastructure that just works. Ship products, not boilerplate.

Frameworks

  • svc-infra
  • ai-infra
  • fin-infra
  • robo-infra

Resources

  • Getting Started
  • What's New
  • Contributing

Community

  • GitHub

© 2026 nfrax. All rights reserved.

nfrax logonfrax
Start HereWhat's New
GitHub
ai-infra / API Reference

VectorStore

from ai_infra.embeddings import VectorStore
View source
ai_infra.embeddings

Simple vector store for semantic search. Store documents and search by meaning using embeddings. Supports multiple backends: in-memory, Chroma, FAISS. Features: - Simple API: `add()`, `search()`, `delete()` - Multiple backends: memory, chroma, faiss - Auto-embedding: Just add text, embeddings handled automatically - Metadata filtering: Filter search results by metadata

python
from ai_infra import Embeddings, VectorStore

    # Create with embeddings
    embeddings = Embeddings()
    store = VectorStore(embeddings=embeddings)

    # Add documents
    store.add_texts(["Python is great", "JavaScript is popular"])

    # Search
    results = store.search("programming languages", k=2)
    for result in results:
        print(f"{result.score:.2f}: {result.document.text}")

Example - With metadata:

python
store.add_texts(
        texts=["Doc 1", "Doc 2"],
        metadatas=[{"source": "web"}, {"source": "book"}]
    )

    # Filter by metadata
    results = store.search("query", filter={"source": "web"})

Example - Persistent storage with Chroma:

python
store = VectorStore(
        embeddings=embeddings,
        backend="chroma",
        persist_directory="./my_db"
    )
Constructor
VectorStore(embeddings: Embeddings, backend: Literal['memory', 'chroma', 'faiss'] = 'memory', collection_name: str = 'default', persist_directory: str | None = None, kwargs: Any = {}) -> None
ParameterTypeDefaultDescription
embeddingsrequiredEmbeddings—Embeddings instance for generating vectors.
backendLiteral['memory', 'chroma', 'faiss']'memory'Storage backend - "memory", "chroma", or "faiss".
collection_namestr'default'Name for the collection (chroma only).
persist_directorystr|NoneNoneDirectory for persistent storage.
kwargsAny{}—

Methods

On This Page

Constructoradd_documentsadd_textsasearchasynccleardeletesearch