@langchain/community
Version:
Third-party integrations for LangChain.js
1 lines • 17.4 kB
Source Map (JSON)
{"version":3,"file":"azion_edgesql.d.cts","names":["VectorStore","EmbeddingsInterface","Document","AzionFilter","Operator","Column","AzionSetupOptions","HybridSearchOptions","FullTextSearchOptions","SimilaritySearchOptions","AzionVectorStoreArgs","AzionVectorStore","Promise","Record"],"sources":["../../src/vectorstores/azion_edgesql.d.ts"],"sourcesContent":["import { VectorStore } from \"@langchain/core/vectorstores\";\nimport type { EmbeddingsInterface } from \"@langchain/core/embeddings\";\nimport { Document } from \"@langchain/core/documents\";\n/**\n * Represents a filter condition for querying the Azion database\n * @property operator - The comparison operator to use (e.g. =, !=, >, <, etc)\n * @property column - The database column to filter on\n * @property value - The value to compare against\n */\nexport type AzionFilter = {\n operator: Operator;\n column: Column;\n value: string;\n};\n/**\n * Represents a database column name\n */\nexport type Column = string;\n/**\n * Valid SQL operators that can be used in filter conditions\n */\nexport type Operator = \"=\" | \"!=\" | \">\" | \"<>\" | \"<\" | \">=\" | \"<=\" | \"LIKE\" | \"NOT LIKE\" | \"IN\" | \"NOT IN\" | \"IS NULL\" | \"IS NOT NULL\";\n/**\n * Interface for configuring the Azion vector store setup\n * @property {string[]} columns - Additional columns to create in the database table. If expandedMetadata is true, this is required.\n * @property {\"vector\" | \"hybrid\"} mode - The search mode to enable:\n * \"vector\" - Only vector similarity search\n * \"hybrid\" - Both vector and full-text search capabilities\n */\ninterface AzionSetupOptions {\n columns?: string[];\n mode: \"vector\" | \"hybrid\";\n}\n/**\n * Interface for configuring hybrid search options that combines vector and full-text search\n * @property {number} kfts - Number of results to return from full-text search\n * @property {number} kvector - Number of results to return from vector similarity search\n * @property {AzionFilter[]} [filter] - Optional array of filters to apply to search results\n * @property {string[]} [metadataItems] - Optional array of metadata fields to include in results\n */\ninterface HybridSearchOptions {\n kfts: number;\n kvector: number;\n filter?: AzionFilter[];\n metadataItems?: string[];\n}\n/**\n * Interface for configuring full-text search options\n * @property {number} kfts - Number of results to return from full-text search\n * @property {AzionFilter[]} [filter] - Optional array of filters to apply to search results\n * @property {string[]} [metadataItems] - Optional array of metadata fields to include in results\n */\ninterface FullTextSearchOptions {\n kfts: number;\n filter?: AzionFilter[];\n metadataItems?: string[];\n}\n/**\n * Interface for configuring vector similarity search options\n * @property {number} kvector - Number of results to return from vector similarity search\n * @property {AzionFilter[]} [filter] - Optional array of filters to apply to search results\n * @property {string[]} [metadataItems] - Optional array of metadata fields to include in results\n */\ninterface SimilaritySearchOptions {\n kvector: number;\n filter?: AzionFilter[];\n metadataItems?: string[];\n}\n/**\n * Interface for the arguments required to initialize an Azion library.\n */\nexport interface AzionVectorStoreArgs {\n tableName: string;\n filter?: AzionFilter[];\n dbName: string;\n expandedMetadata?: boolean;\n}\n/**\n * Example usage:\n * ```ts\n * // Initialize the vector store\n * const vectorStore = new AzionVectorStore(embeddings, {\n * dbName: \"mydb\",\n * tableName: \"documents\"\n * });\n *\n * // Setup database with hybrid search and metadata columns\n * await vectorStore.setupDatabase({\n * columns: [\"topic\", \"language\"],\n * mode: \"hybrid\"\n * });\n *\n *\n * // OR: Initialize using the static create method\n * const vectorStore = await AzionVectorStore.initialize(embeddings, {\n * dbName: \"mydb\",\n * tableName: \"documents\"\n * }, {\n * columns: [\"topic\", \"language\"],\n * mode: \"hybrid\"\n * });\n *\n * By default, the columns are not expanded, meaning that the metadata is stored in a single column:\n *\n * // Setup database with hybrid search and metadata columns\n * await vectorStore.setupDatabase({\n * columns: [\"*\"],\n * mode: \"hybrid\"\n * });\n *\n * // Add documents to the vector store\n * await vectorStore.addDocuments([\n * new Document({\n * pageContent: \"Australia is known for its unique wildlife\",\n * metadata: { topic: \"nature\", language: \"en\" }\n * })\n * ]);\n *\n * // Perform similarity search\n * const results = await vectorStore.similaritySearch(\n * \"coral reefs in Australia\",\n * 2, // Return top 2 results\n * { filter: [{ operator: \"=\", column: \"topic\", string: \"biology\" }] } // Optional AzionFilter\n * );\n *\n * // Perform full text search\n * const ftResults = await vectorStore.fullTextSearch(\n * \"Sydney Opera House\",\n * 1, // Return top result\n * { filter: [{ operator: \"=\", column: \"language\", string: \"en\" }] } // Optional AzionFilter\n * );\n * ```\n */\nexport declare class AzionVectorStore extends VectorStore {\n /** Type declaration for filter type */\n FilterType: AzionFilter[];\n /** Name of the main table to store vectors and documents */\n tableName: string;\n /** Name of the database to use */\n dbName: string;\n /** Whether the metadata is contained in a single column or multiple columns */\n expandedMetadata: boolean;\n _vectorstoreType(): string;\n constructor(embeddings: EmbeddingsInterface, args: AzionVectorStoreArgs);\n /**\n * Creates a new vector store instance and sets up the database.\n * @param {EmbeddingsInterface} embeddings - The embeddings interface to use for vectorizing documents\n * @param {AzionVectorStoreArgs} args - Configuration options:\n * @param {string} args.dbName - Name of the database to create/use\n * @param {string} args.tableName - Name of the table to create/use\n * @param {AzionSetupOptions} setupOptions - Database setup options:\n * @param {string[]} setupOptions.columns - Additional columns to create in the table beyond the required ones. If expandedMetadata is true, this is required.\n * @param {\"vector\"|\"hybrid\"} setupOptions.mode - The search mode to enable:\n * - \"vector\": Only vector similarity search capabilities\n * - \"hybrid\": Both vector and full-text search capabilities\n * @returns {Promise<AzionVectorStore>} A promise that resolves with the configured vector store instance\n */\n static initialize(embeddings: EmbeddingsInterface, args: AzionVectorStoreArgs, setupOptions: AzionSetupOptions): Promise<AzionVectorStore>;\n /**\n * Adds documents to the vector store.\n * @param {Document[]} documents The documents to add.\n * @param {Object} options Optional parameters for adding the documents.\n * @returns A promise that resolves when the documents have been added.\n */\n addDocuments(documents: Document[]): Promise<void>;\n /**\n * Adds vectors to the vector store.\n * @param {number[][]} vectors The vectors to add.\n * @param {Document[]} documents The documents associated with the vectors.\n * @param {Object} options Optional parameters for adding the vectors.\n * @returns A promise that resolves with the IDs of the added vectors when the vectors have been added.\n */\n addVectors(vectors: number[][], documents: Document[]): Promise<void>;\n private getEmbeddingsDimensions;\n private mapRowsFromDocuments;\n /**\n * Sets up the database and tables.\n * @param {AzionSetupOptions} setupOptions The setup options:\n * - columns: string[] - The metadata columns to add to the table\n * - mode: \"vector\" | \"hybrid\" - The mode to use for the table. \"vector\" for vector search only, \"hybrid\" for vector and full-text search\n * @returns {Promise<void>} A promise that resolves when the database and tables have been set up.\n */\n setupDatabase(setupOptions: AzionSetupOptions): Promise<void>;\n private handleTables;\n /**\n * Handles the error.\n * @param {Object} error The error object.\n * @param {string} message The message to display.\n * @returns {void} A void value.\n */\n private errorHandler;\n /**\n * Checks if the tables are setup.\n * @param {string | number | string[] | number[]} tables The tables.\n * @param {string} mode The mode.\n * @returns {boolean} Whether the tables are setup.\n */\n private areTablesSetup;\n private handleDatabase;\n private waitDatabaseCreation;\n private setupTables;\n private insertChunks;\n /**\n * Extracts the metadata columns from the rows.\n * @param {RowsInterface[]} rows The rows to extract the metadata columns from.\n * @returns {string[]} The metadata columns.\n */\n private extractMetadataColumns;\n /**\n * Creates the insert statement for a row.\n * @param {RowsInterface} row The row to create the insert statement for.\n * @param {string[]} metadataColumns The metadata columns.\n * @returns {string} The insert statement.\n */\n private createInsertStatement;\n /**\n * Creates the insert statements for the rows.\n * @param {RowsInterface[]} rows The rows to create the insert statements for.\n * @returns {string[]} The insert statements.\n */\n private createStatements;\n /**\n * Creates the insert chunks for the statements.\n * @param {string[]} statements The statements to create the insert chunks for.\n * @returns {string[][]} The insert chunks.\n */\n private createInsertChunks;\n /**\n * Gets the number of bytes in a string.\n * @param {string} str The string to get the number of bytes for.\n * @returns {number} The number of bytes in the string.\n */\n private getStringBytes;\n /**\n * Performs a similarity search on the vector store and returns the top 'similarityK' similar documents.\n * @param {number[]} vector The vector to search for.\n * @param {number} k The number of documents to return.\n * @param {AzionFilter[]} filter Optional filters to apply to the search.\n * @param {string[]} metadataItems Optional metadata items to include in the search.\n * @returns {Promise<[Document, number][]>} A promise that resolves with the similarity search results when the search is complete.\n */\n similaritySearchVectorWithScore(vector: number[], k: number, filter?: AzionFilter[], metadataItems?: string[]): Promise<[Document, number][]>;\n /**\n * Performs a full-text search on the vector store and returns the top 'k' similar documents.\n * @param query The query string to search for\n * @param options The options for the full-text search, including:\n * - kfts: The number of full-text search results to return\n * - filter: Optional filters to apply to narrow down the search results\n * - metadataItems: Optional metadata fields to include in the results\n * @returns A promise that resolves with the full-text search results when the search is complete.\n */\n azionFullTextSearch(query: string, options: FullTextSearchOptions): Promise<[Document<Record<string, any>>, number][]>;\n /**\n * Performs a hybrid search on the vector store and returns the top 'k' similar documents.\n * @param query The query string to search for\n * @param options The options for the hybrid search, including:\n * - kfts: The number of full-text search results to return\n * - kvector: The number of vector search results to return\n * - filter: Optional filters to apply to narrow down the search results\n * - metadataItems: Optional metadata fields to include in the results\n * @returns A promise that resolves with the hybrid search results when the search is complete.\n */\n azionHybridSearch(query: string, hybridSearchOptions: HybridSearchOptions): Promise<[Document, number][]>;\n /**\n * Performs a similarity search on the vector store and returns the top 'k' similar documents.\n * @param query The query string.\n * @param options The options for the similarity search, including:\n * - kvector: The number of vector search results to return\n * - filter: Optional filters to apply to the search\n * - metadataItems: Optional metadata fields to include in results\n * @returns A promise that resolves with the similarity search results when the search is complete.\n */\n azionSimilaritySearch(query: string, options: SimilaritySearchOptions): Promise<[Document, number][]>;\n /**\n * Generates an error document based on the provided error information\n * @param {Object} error The error object containing details about the issue\n * @returns {Promise<[Document, number][]>} A promise that resolves to an array containing a single Document representing the error\n */\n private searchError;\n /**\n * Deletes documents from the vector store.\n * @param {string[]} ids The IDs of the documents to delete.\n * @returns {Promise<void>} A promise that resolves when the documents have been deleted.\n */\n delete(ids: string[]): Promise<void>;\n /**\n * Removes duplicate results from the search results, prioritizing a mix of similarity and FTS results.\n * @param {[Document, number][]} results - The array of search results to process, containing document and score pairs\n * @param {number} kfts - Maximum number of full-text search results to include\n * @param {number} kvector - Maximum number of vector similarity search results to include\n * @returns {[Document, number][]} An array of unique search results, limited by kfts and kvector parameters\n */\n private removeDuplicates;\n /**\n * Converts query results to SearchEmbeddingsResponse objects.\n * @param {QueryResult[]} results - The raw query results from the database.\n * @returns {SearchEmbeddingsResponse[]} An array of SearchEmbeddingsResponse objects.\n */\n private mapRows;\n /**\n * Maps search results to Document objects.\n * @param {SearchEmbeddingsResponse[]} searches An array of SearchEmbeddingsResponse objects.\n * @returns An array of tuples, each containing a single Document object.\n */\n private mapSearches;\n /**\n * Generates the metadata string for the SQL query.\n * @param {string[]} metadataItems - The metadata items to include in the query.\n * @param {string} searchType - The type of search.\n * @returns {string} The metadata string.\n */\n private generateMetadata;\n /**\n * Generates the filters string for the SQL query.\n * @param {AzionFilter[]} filters The filters to apply to the query.\n * @returns {string} The filters string.\n */\n private generateFilters;\n /**\n * Creates the insert sql query for a row.\n * @param {string[]} columnNames The column names.\n * @param {string[]} values The values.\n * @returns {string} The insert sql query.\n */\n private createInsertString;\n /**\n * Escapes the quotes in the value.\n * @param {string} value The value to escape the quotes in.\n * @returns {string} The value with the quotes escaped.\n */\n private escapeQuotes;\n /**\n * Sanitizes an item by removing non-alphanumeric characters.\n * @param {string} item The item to sanitize.\n * @returns {string} The sanitized item.\n */\n private sanitizeItem;\n /**\n * Converts a query to a FTS query.\n * @param query The user query\n * @returns The converted FTS query\n */\n protected convert2FTSQuery(query: string): string;\n}\nexport {};\n//# sourceMappingURL=azion_edgesql.d.ts.map"],"mappings":";;;;;;;;AASA;AAQA;AAIA;AAAuI;AAmB7HO,KA/BEJ,WAAAA,GA+BiB;EAYnBK,QAAAA,EA1CIJ,QA0CJI;EAWAC,MAAAA,EApDEJ,MAoDFI;EAQOC,KAAAA,EAAAA,MAAAA;AA8DjB,CAAA;;;;AAwBkCT,KA5ItBI,MAAAA,GA4IsBJ,MAAAA;;;;AAAmFW,KAxIzGR,QAAAA,GAwIyGQ,GAAAA,GAAAA,IAAAA,GAAAA,GAAAA,GAAAA,IAAAA,GAAAA,GAAAA,GAAAA,IAAAA,GAAAA,IAAAA,GAAAA,MAAAA,GAAAA,UAAAA,GAAAA,IAAAA,GAAAA,QAAAA,GAAAA,SAAAA,GAAAA,aAAAA;;;;;;;;U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