UNPKG

@langchain/community

Version:
1 lines • 5.45 kB
{"version":3,"file":"usearch.d.ts","names":["Index","EmbeddingsInterface","SaveableVectorStore","Document","SynchronousInMemoryDocstore","USearchArgs","Record","USearch","Promise"],"sources":["../../src/vectorstores/usearch.d.ts"],"sourcesContent":["import { Index } from \"usearch\";\nimport type { EmbeddingsInterface } from \"@langchain/core/embeddings\";\nimport { SaveableVectorStore } from \"@langchain/core/vectorstores\";\nimport { Document } from \"@langchain/core/documents\";\nimport { SynchronousInMemoryDocstore } from \"../stores/doc/in_memory.js\";\n/**\n * Interface that defines the arguments that can be passed to the\n * `USearch` constructor. It includes optional properties for a\n * `docstore`, `index`, and `mapping`.\n */\nexport interface USearchArgs {\n docstore?: SynchronousInMemoryDocstore;\n index?: Index;\n mapping?: Record<number, string>;\n}\n/**\n * Class that extends `SaveableVectorStore` and provides methods for\n * adding documents and vectors to a `usearch` index, performing\n * similarity searches, and saving the index.\n */\nexport declare class USearch extends SaveableVectorStore {\n _index?: Index;\n _mapping: Record<number, string>;\n docstore: SynchronousInMemoryDocstore;\n args: USearchArgs;\n _vectorstoreType(): string;\n constructor(embeddings: EmbeddingsInterface, args: USearchArgs);\n /**\n * Method that adds documents to the `usearch` index. It generates\n * embeddings for the documents and adds them to the index.\n * @param documents An array of `Document` instances to be added to the index.\n * @returns A promise that resolves with an array of document IDs.\n */\n addDocuments(documents: Document[]): Promise<string[]>;\n get index(): Index;\n private set index(value);\n /**\n * Method that adds vectors to the `usearch` index. It also updates the\n * mapping between vector IDs and document IDs.\n * @param vectors An array of vectors to be added to the index.\n * @param documents An array of `Document` instances corresponding to the vectors.\n * @returns A promise that resolves with an array of document IDs.\n */\n addVectors(vectors: number[][], documents: Document[]): Promise<string[]>;\n /**\n * Method that performs a similarity search in the `usearch` index. It\n * returns the `k` most similar documents to a given query vector, along\n * with their similarity scores.\n * @param query The query vector.\n * @param k The number of most similar documents to return.\n * @returns A promise that resolves with an array of tuples, each containing a `Document` and its similarity score.\n */\n similaritySearchVectorWithScore(query: number[], k: number): Promise<[Document<Record<string, any>>, number][]>;\n /**\n * Method that saves the `usearch` index and the document store to disk.\n * @param directory The directory where the index and document store should be saved.\n * @returns A promise that resolves when the save operation is complete.\n */\n save(directory: string): Promise<void>;\n /**\n * Static method that creates a new `USearch` instance from a list of\n * texts. It generates embeddings for the texts and adds them to the\n * `usearch` index.\n * @param texts An array of texts to be added to the index.\n * @param metadatas Metadata associated with the texts.\n * @param embeddings An instance of `Embeddings` used to generate embeddings for the texts.\n * @param dbConfig Optional configuration for the document store.\n * @returns A promise that resolves with a new `USearch` instance.\n */\n static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig?: {\n docstore?: SynchronousInMemoryDocstore;\n }): Promise<USearch>;\n /**\n * Static method that creates a new `USearch` instance from a list of\n * documents. It generates embeddings for the documents and adds them to\n * the `usearch` index.\n * @param docs An array of `Document` instances to be added to the index.\n * @param embeddings An instance of `Embeddings` used to generate embeddings for the documents.\n * @param dbConfig Optional configuration for the document store.\n * @returns A promise that resolves with a new `USearch` instance.\n */\n static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig?: {\n docstore?: SynchronousInMemoryDocstore;\n }): Promise<USearch>;\n}\n//# sourceMappingURL=usearch.d.ts.map"],"mappings":";;;;;;;;;;AAUA;;;AAGcM,UAHGD,WAAAA,CAGHC;EAAM,QAAA,CAAA,EAFLF,mBAAAA,CAAAA,2BAEK;EAOCG,KAAAA,CAAAA,EARTP,KAQgB;EACfA,OAAAA,CAAAA,EARCM,MAQDN,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;;;;;;;AAY4BQ,cAbpBD,OAAAA,SAAgBL,mBAAAA,CAaIM;EACxBR,MAAAA,CAAAA,EAbJA,KAaIA;EAS8BG,QAAAA,EArBjCG,MAqBiCH,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;EAAaK,QAAAA,EApB9CJ,mBAAAA,CAAAA,2BAoB8CI;EASuBF,IAAAA,EA5BzED,WA4ByEC;EAATH,gBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAATK,WAAAA,CAAAA,UAAAA,EA1BrCP,mBA0BqCO,EAAAA,IAAAA,EA1BVH,WA0BUG;EAMpCA;;;;;;EAuB0BP,YAAAA,CAAAA,SAAAA,EAhD3BE,QAgD2BF,EAAAA,CAAAA,EAhDdO,OAgDcP,CAAAA,MAAAA,EAAAA,CAAAA;EACpCG,IAAAA,KAAAA,CAAAA,CAAAA,EAhDFJ,KAgDEI;EACHG,YAAAA,KAAAA,CAAAA,KAAAA;EAARC;;AA/DgD;;;;;6CAuBTL,aAAaK;;;;;;;;;+DASKA,SAASL,SAASG;;;;;;2BAMtDE;;;;;;;;;;;8EAWmDP;eAC7DG,mBAAAA,CAAAA;MACXI,QAAQD;;;;;;;;;;6BAUeJ,wBAAwBF;eACpCG,mBAAAA,CAAAA;MACXI,QAAQD"}