UNPKG

@langchain/community

Version:
1 lines • 12.7 kB
{"version":3,"file":"azure_aisearch.d.ts","names":["SearchClient","SearchIndexClient","SearchIndex","VectorFilterMode","KeyCredential","TokenCredential","MaxMarginalRelevanceSearchOptions","VectorStore","EmbeddingsInterface","Document","AzureAISearchQueryType","AzureAISearchQueryOptions","AzureAISearchConfig","AzureAISearchDocument","AzureAISearchDocumentMetadata","Array","AzureAISearchAddDocumentsOptions","AzureAISearchFilterType","AzureAISearchVectorStore","Promise"],"sources":["../../src/vectorstores/azure_aisearch.d.ts"],"sourcesContent":["import { SearchClient, SearchIndexClient, SearchIndex, VectorFilterMode } from \"@azure/search-documents\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { MaxMarginalRelevanceSearchOptions, VectorStore } from \"@langchain/core/vectorstores\";\nimport type { EmbeddingsInterface } from \"@langchain/core/embeddings\";\nimport { Document } from \"@langchain/core/documents\";\n/**\n * Azure AI Search query type.\n */\nexport declare const AzureAISearchQueryType: {\n /** Vector search. */\n readonly Similarity: \"similarity\";\n /** Hybrid full text and vector search. */\n readonly SimilarityHybrid: \"similarity_hybrid\";\n /** Hybrid full text and vector search with semantic ranking. */\n readonly SemanticHybrid: \"semantic_hybrid\";\n};\n/**\n * Azure AI Search query type.\n */\nexport type AzureAISearchQueryType = (typeof AzureAISearchQueryType)[keyof typeof AzureAISearchQueryType];\n/**\n * Azure AI Search settings.\n */\nexport interface AzureAISearchQueryOptions {\n readonly type?: AzureAISearchQueryType;\n readonly semanticConfigurationName?: string;\n}\n/**\n * Configuration options for the `AzureAISearchStore` constructor.\n */\nexport interface AzureAISearchConfig {\n readonly client?: SearchClient<AzureAISearchDocument>;\n readonly indexName?: string;\n readonly endpoint?: string;\n readonly key?: string;\n readonly credentials?: KeyCredential | TokenCredential;\n readonly search?: AzureAISearchQueryOptions;\n}\n/**\n * Azure AI Search options metadata schema.\n * If yout want to add custom data, use the attributes property.\n */\nexport type AzureAISearchDocumentMetadata = {\n source: string;\n attributes?: Array<{\n key: string;\n value: string;\n }>;\n embedding?: number[];\n};\n/**\n * Azure AI Search indexed document.\n */\nexport type AzureAISearchDocument = {\n id: string;\n content: string;\n content_vector: number[];\n metadata: AzureAISearchDocumentMetadata;\n};\n/**\n * Azure AI Search options for adding documents.\n */\nexport type AzureAISearchAddDocumentsOptions = {\n ids?: string[];\n};\n/**\n * Azure AI Search filter type.\n */\nexport type AzureAISearchFilterType = {\n /** OData filter. */\n filterExpression?: string;\n /** Determines whether or not filters are applied before or after the vector search is performed. */\n vectorFilterMode?: VectorFilterMode;\n /** Determines whether or not to include the embeddings in the search results. */\n includeEmbeddings?: boolean;\n};\n/**\n * Azure AI Search vector store.\n * To use this, you should have:\n * - the `@azure/search-documents` NPM package installed\n * - an endpoint and key to the Azure AI Search instance\n *\n * If you directly provide a `SearchClient` instance, you need to ensure that\n * an index has been created. When using and endpoint and key, the index will\n * be created automatically if it does not exist.\n */\nexport declare class AzureAISearchVectorStore extends VectorStore {\n FilterType: AzureAISearchFilterType;\n get lc_secrets(): {\n [key: string]: string;\n };\n _vectorstoreType(): string;\n private readonly initPromise;\n private readonly client;\n private readonly indexName;\n private readonly options;\n constructor(embeddings: EmbeddingsInterface, config: AzureAISearchConfig);\n /**\n * Removes specified documents from the AzureAISearchVectorStore using IDs or a filter.\n * @param params Object that includes either an array of IDs or a filter for the data to be deleted.\n * @returns A promise that resolves when the documents have been removed.\n */\n delete(params: {\n ids?: string | string[];\n filter?: AzureAISearchFilterType;\n }): Promise<void>;\n private deleteMany;\n private deleteById;\n /**\n * Adds documents to the AzureAISearchVectorStore.\n * @param documents The documents to add.\n * @param options Options for adding documents.\n * @returns A promise that resolves to the ids of the added documents.\n */\n addDocuments(documents: Document[], options?: AzureAISearchAddDocumentsOptions): Promise<string[]>;\n /**\n * Adds vectors to the AzureAISearchVectorStore.\n * @param vectors Vectors to be added.\n * @param documents Corresponding documents to be added.\n * @param options Options for adding documents.\n * @returns A promise that resolves to the ids of the added documents.\n */\n addVectors(vectors: number[][], documents: Document[], options?: AzureAISearchAddDocumentsOptions): Promise<string[]>;\n /**\n * Performs a similarity search using query type specified in configuration.\n * If the query type is not specified, it defaults to similarity search.\n * @param query Query text for the similarity search.\n * @param k=4 Number of nearest neighbors to return.\n * @param filter Optional filter options for the documents.\n * @returns Promise that resolves to a list of documents.\n */\n similaritySearch(query: string, k?: number, filter?: this[\"FilterType\"] | undefined): Promise<Document[]>;\n /**\n * Performs a similarity search using query type specified in configuration.\n * If the query type is not specified, it defaults to similarity hybrid search.\n * @param query Query text for the similarity search.\n * @param k=4 Number of nearest neighbors to return.\n * @param filter Optional filter options for the documents.\n * @returns Promise that resolves to a list of documents and their corresponding similarity scores.\n */\n similaritySearchWithScore(query: string, k?: number, filter?: this[\"FilterType\"] | undefined): Promise<[Document, number][]>;\n /**\n * Performs a hybrid search using query text.\n * @param query Query text for the similarity search.\n * @param queryVector Query vector for the similarity search.\n * If not provided, the query text will be embedded.\n * @param k=4 Number of nearest neighbors to return.\n * @param filter Optional filter options for the documents.\n * @returns Promise that resolves to a list of documents and their corresponding similarity scores.\n */\n hybridSearchVectorWithScore(query: string, queryVector?: number[], k?: number, filter?: this[\"FilterType\"] | undefined): Promise<[Document, number][]>;\n /**\n * Performs a hybrid search with semantic reranker using query text.\n * @param query Query text for the similarity search.\n * @param queryVector Query vector for the similarity search.\n * If not provided, the query text will be embedded.\n * @param k=4 Number of nearest neighbors to return.\n * @param filter Optional filter options for the documents.\n * @returns Promise that resolves to a list of documents and their corresponding similarity scores.\n */\n semanticHybridSearchVectorWithScore(query: string, queryVector?: number[], k?: number, filter?: this[\"FilterType\"] | undefined): Promise<[Document, number][]>;\n /**\n * Performs a similarity search on the vectors stored in the collection.\n * @param queryVector Query vector for the similarity search.\n * @param k=4 Number of nearest neighbors to return.\n * @param filter Optional filter options for the documents.\n * @returns Promise that resolves to a list of documents and their corresponding similarity scores.\n */\n similaritySearchVectorWithScore(query: number[], k: number, filter?: this[\"FilterType\"]): Promise<[Document, number][]>;\n /**\n * Return documents selected using the maximal marginal relevance.\n * Maximal marginal relevance optimizes for similarity to the query AND\n * diversity among selected documents.\n * @param query Text to look up documents similar to.\n * @param options.k Number of documents to return.\n * @param options.fetchK=20 Number of documents to fetch before passing to\n * the MMR algorithm.\n * @param options.lambda=0.5 Number between 0 and 1 that determines the\n * degree of diversity among the results, where 0 corresponds to maximum\n * diversity and 1 to minimum diversity.\n * @returns List of documents selected by maximal marginal relevance.\n */\n maxMarginalRelevanceSearch(query: string, options: MaxMarginalRelevanceSearchOptions<this[\"FilterType\"]>): Promise<Document[]>;\n /**\n * Ensures that an index exists on the AzureAISearchVectorStore.\n * @param indexClient The Azure AI Search index client.\n * @returns A promise that resolves when the AzureAISearchVectorStore index has been initialized.\n * @protected\n */\n protected ensureIndexExists(indexClient: SearchIndexClient): Promise<void>;\n /**\n * Prepares the search index definition for Azure AI Search.\n * @param indexName The name of the index.\n * @returns The SearchIndex object.\n * @protected\n */\n protected createSearchIndexDefinition(indexName: string): Promise<SearchIndex>;\n /**\n * Static method to create an instance of AzureAISearchVectorStore from a\n * list of texts. It first converts the texts to vectors and then adds\n * them to the collection.\n * @param texts List of texts to be converted to vectors.\n * @param metadatas Metadata for the texts.\n * @param embeddings Embeddings to be used for conversion.\n * @param config Database configuration for Azure AI Search.\n * @returns Promise that resolves to a new instance of AzureAISearchVectorStore.\n */\n static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, config: AzureAISearchConfig): Promise<AzureAISearchVectorStore>;\n /**\n * Static method to create an instance of AzureAISearchVectorStore from a\n * list of documents. It first converts the documents to vectors and then\n * adds them to the database.\n * @param docs List of documents to be converted to vectors.\n * @param embeddings Embeddings to be used for conversion.\n * @param config Database configuration for Azure AI Search.\n * @returns Promise that resolves to a new instance of AzureAISearchVectorStore.\n */\n static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, config: AzureAISearchConfig, options?: AzureAISearchAddDocumentsOptions): Promise<AzureAISearchVectorStore>;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