@langchain/community
Version:
Third-party integrations for LangChain.js
1 lines • 8.35 kB
Source Map (JSON)
{"version":3,"file":"milvus.d.cts","names":["MilvusClient","ClientConfig","keyValueObj","EmbeddingsInterface","VectorStore","Document","MilvusLibArgs","IndexCreateOptions","IndexType","MetricType","Milvus","Promise"],"sources":["../../src/vectorstores/milvus.d.ts"],"sourcesContent":["import { MilvusClient, ClientConfig, keyValueObj } from \"@zilliz/milvus2-sdk-node\";\nimport type { EmbeddingsInterface } from \"@langchain/core/embeddings\";\nimport { VectorStore } from \"@langchain/core/vectorstores\";\nimport { Document } from \"@langchain/core/documents\";\n/**\n * Interface for the arguments required by the Milvus class constructor.\n */\nexport interface MilvusLibArgs {\n collectionName?: string;\n partitionName?: string;\n primaryField?: string;\n vectorField?: string;\n textField?: string;\n url?: string;\n ssl?: boolean;\n username?: string;\n password?: string;\n textFieldMaxLength?: number;\n clientConfig?: ClientConfig;\n autoId?: boolean;\n indexCreateOptions?: IndexCreateOptions;\n partitionKey?: string;\n partitionKeyMaxLength?: number;\n}\nexport interface IndexCreateOptions {\n index_type: IndexType;\n metric_type: MetricType;\n params?: keyValueObj;\n search_params?: keyValueObj;\n}\nexport type MetricType = \"L2\" | \"IP\" | \"COSINE\";\n/**\n * Type representing the type of index used in the Milvus database.\n */\ntype IndexType = \"FLAT\" | \"IVF_FLAT\" | \"IVF_SQ8\" | \"IVF_PQ\" | \"HNSW\" | \"RHNSW_FLAT\" | \"RHNSW_SQ\" | \"RHNSW_PQ\" | \"IVF_HNSW\" | \"ANNOY\";\n/**\n * Class for interacting with a Milvus database. Extends the VectorStore\n * class.\n */\nexport declare class Milvus extends VectorStore {\n embeddings: EmbeddingsInterface;\n get lc_secrets(): {\n [key: string]: string;\n };\n _vectorstoreType(): string;\n FilterType: string;\n collectionName: string;\n partitionName?: string;\n numDimensions?: number;\n autoId?: boolean;\n primaryField: string;\n vectorField: string;\n textField: string;\n textFieldMaxLength: number;\n partitionKey?: string;\n partitionKeyMaxLength?: number;\n fields: string[];\n client: MilvusClient;\n indexCreateParams: IndexCreateOptions;\n indexSearchParams: keyValueObj;\n constructor(embeddings: EmbeddingsInterface, args: MilvusLibArgs);\n /**\n * Adds documents to the Milvus database.\n * @param documents Array of Document instances to be added to the database.\n * @param options Optional parameter that can include specific IDs for the documents.\n * @returns Promise resolving to void.\n */\n addDocuments(documents: Document[], options?: {\n ids?: string[];\n }): Promise<void>;\n /**\n * Adds vectors to the Milvus database.\n * @param vectors Array of vectors to be added to the database.\n * @param documents Array of Document instances associated with the vectors.\n * @param options Optional parameter that can include specific IDs for the documents.\n * @returns Promise resolving to void.\n */\n addVectors(vectors: number[][], documents: Document[], options?: {\n ids?: string[];\n }): Promise<void>;\n /**\n * Searches for vectors in the Milvus database that are similar to a given\n * vector.\n * @param query Vector to compare with the vectors in the database.\n * @param k Number of similar vectors to return.\n * @param filter Optional filter to apply to the search.\n * @returns Promise resolving to an array of tuples, each containing a Document instance and a similarity score.\n */\n similaritySearchVectorWithScore(query: number[], k: number, filter?: string): Promise<[Document, number][]>;\n /**\n * Ensures that a collection exists in the Milvus database.\n * @param vectors Optional array of vectors to be used if a new collection needs to be created.\n * @param documents Optional array of Document instances to be used if a new collection needs to be created.\n * @returns Promise resolving to void.\n */\n ensureCollection(vectors?: number[][], documents?: Document[]): Promise<void>;\n /**\n * Ensures that a partition exists in the Milvus collection.\n * @returns Promise resolving to void.\n */\n ensurePartition(): Promise<void>;\n /**\n * Creates a collection in the Milvus database.\n * @param vectors Array of vectors to be added to the new collection.\n * @param documents Array of Document instances to be added to the new collection.\n * @returns Promise resolving to void.\n */\n createCollection(vectors: number[][], documents: Document[]): Promise<void>;\n /**\n * Retrieves the fields of a collection in the Milvus database.\n * @returns Promise resolving to void.\n */\n grabCollectionFields(): Promise<void>;\n /**\n * Creates a Milvus instance from a set of texts and their associated\n * metadata.\n * @param texts Array of texts to be added to the database.\n * @param metadatas Array of metadata objects associated with the texts.\n * @param embeddings Embeddings instance used to generate vector embeddings for the texts.\n * @param dbConfig Optional configuration for the Milvus database.\n * @returns Promise resolving to a new Milvus instance.\n */\n static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig?: MilvusLibArgs): Promise<Milvus>;\n /**\n * Creates a Milvus instance from a set of Document instances.\n * @param docs Array of Document instances to be added to the database.\n * @param embeddings Embeddings instance used to generate vector embeddings for the documents.\n * @param dbConfig Optional configuration for the Milvus database.\n * @returns Promise resolving to a new Milvus instance.\n */\n static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig?: MilvusLibArgs): Promise<Milvus>;\n /**\n * Creates a Milvus instance from an existing collection in the Milvus\n * database.\n * @param embeddings Embeddings instance used to generate vector embeddings for the documents in the collection.\n * @param dbConfig Configuration for the Milvus database.\n * @returns Promise resolving to a new Milvus instance.\n */\n static fromExistingCollection(embeddings: EmbeddingsInterface, dbConfig: MilvusLibArgs): Promise<Milvus>;\n /**\n * Deletes data from the Milvus database.\n * @param params Object containing a filter to apply to the deletion.\n * @returns Promise resolving to void.\n */\n delete(params: {\n filter?: string;\n ids?: string[];\n }): Promise<void>;\n}\nexport {};\n//# sourceMappingURL=milvus.d.ts.map"],"mappings":";;;;;;;;;AAOA;AAiBiBO,UAjBAD,aAAAA,CAiBkB;EACnBE,cAAAA,CAAAA,EAAAA,MAAAA;EACCC,aAAAA,CAAAA,EAAAA,MAAAA;EACJP,YAAAA,CAAAA,EAAAA,MAAAA;EACOA,WAAAA,CAAAA,EAAAA,MAAAA;EAAW,SAAA,CAAA,EAAA,MAAA;EAEnBO,GAAAA,CAAAA,EAAAA,MAAAA;EAIPD,GAAAA,CAAAA,EAAAA,OAAS;EAKOE,QAAAA,CAAM,EAAA,MAAA;EACXP,QAAAA,CAAAA,EAAAA,MAAAA;EAiBJH,kBAAAA,CAAAA,EAAAA,MAAAA;EACWO,YAAAA,CAAAA,EAxCJN,YAwCIM;EACAL,MAAAA,CAAAA,EAAAA,OAAAA;EACKC,kBAAAA,CAAAA,EAxCHI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