UNPKG

@jackhua/mini-langchain

Version:

A lightweight TypeScript implementation of LangChain with cost optimization features

65 lines 1.91 kB
/** * In-memory vector store implementation */ import { VectorStore, Embeddings } from './base'; import { Document } from '../core/types'; /** * Simple in-memory vector store */ export declare class MemoryVectorStore extends VectorStore { private vectors; private documents; constructor(embeddings: Embeddings); /** * Add documents to the vector store */ addDocuments(documents: Document[]): Promise<string[]>; /** * Add vectors directly */ addVectors(vectors: number[][], documents: Document[]): Promise<string[]>; /** * Similarity search */ similaritySearch(query: string, k?: number, filter?: Record<string, any>): Promise<Document[]>; /** * Similarity search with score */ similaritySearchWithScore(query: string, k?: number, filter?: Record<string, any>): Promise<[Document, number][]>; /** * Similarity search by vector */ similaritySearchVectorWithScore(query: number[], k: number, filter?: Record<string, any>): Promise<[Document, number][]>; /** * Delete documents */ delete(params?: { ids?: string[]; filter?: Record<string, any>; }): Promise<void>; /** * Calculate cosine similarity between two vectors */ private cosineSimilarity; /** * Check if metadata matches filter */ private matchesFilter; /** * Create from texts */ static fromTexts(texts: string[], metadatas: Record<string, any>[] | Record<string, any>, embeddings: Embeddings): Promise<MemoryVectorStore>; /** * Create from documents */ static fromDocuments(docs: Document[], embeddings: Embeddings): Promise<MemoryVectorStore>; /** * Get all documents */ getAllDocuments(): Document[]; /** * Get document count */ getDocumentCount(): number; } //# sourceMappingURL=memory.d.ts.map