Interface for vector store implementations.

Vector stores persist documents with their embeddings and enable semantic similarity search.

const store = new InMemoryVectorStore(llmProvider);

// Add documents
await store.add([
{ id: '1', content: 'AI agents are autonomous software entities' },
{ id: '2', content: 'Machine learning powers modern AI systems' }
]);

// Semantic search
const results = await store.search({
query: 'What are AI agents?',
limit: 3,
minScore: 0.7
});

console.log(results[0].document.content);
console.log(`Relevance: ${results[0].score}`);
interface VectorStore {
    add(documents: Document[]): Promise<number>;
    search(query: VectorSearchQuery): Promise<VectorSearchResult[]>;
    get(id: string): Promise<null | Document>;
    update(id: string, document: Partial<Document>): Promise<boolean>;
    delete(id: string): Promise<boolean>;
    deleteMany(filter: MetadataFilter): Promise<number>;
    count(): Promise<number>;
    clear(): Promise<void>;
    listAll(filter?: MetadataFilter): Promise<Document[]>;
}

Methods

  • Add documents to the vector store

    Parameters

    • documents: Document[]

      Documents to add (embeddings will be generated if not provided)

    Returns Promise<number>

    Number of documents added

  • Update a document

    Parameters

    • id: string

      Document ID

    • document: Partial<Document>

      Updated document

    Returns Promise<boolean>

    true if updated, false if not found

  • Delete a document

    Parameters

    • id: string

      Document ID

    Returns Promise<boolean>

    true if deleted, false if not found