{"version":3,"file":"azion_edgesql.d.cts","names":["EmbeddingsInterface","Document","BaseRetriever","BaseRetrieverInput","BaseChatModel","AzionFilter","Operator","Column","SearchEmbeddingsResponse","AzionRetrieverArgs","AzionRetriever","Promise","Error"],"sources":["../../src/retrievers/azion_edgesql.d.ts"],"sourcesContent":["import type { EmbeddingsInterface } from \"@langchain/core/embeddings\";\nimport { Document } from \"@langchain/core/documents\";\nimport { BaseRetriever, BaseRetrieverInput } from \"@langchain/core/retrievers\";\nimport { BaseChatModel } from \"@langchain/core/language_models/chat_models\";\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 the response returned when searching embeddings.\n */\ninterface SearchEmbeddingsResponse {\n    id: number;\n    content: string;\n    metadata: {\n        searchtype: string;\n        [key: string]: unknown;\n    };\n}\n/**\n * Interface for the arguments required to initialize an Azion library.\n */\nexport interface AzionRetrieverArgs extends BaseRetrieverInput {\n    /**\n     * Search type to perform. Cosine similarity and hybrid (vector + FTS) are currently supported.\n     */\n    searchType?: \"hybrid\" | \"similarity\";\n    /**\n     * The number of documents retrieved with cosine similarity (vector) search. Minimum is 1.\n     */\n    similarityK?: number;\n    /**\n     * The number of documents retrieved with full text search. Minimum is 1.\n     */\n    ftsK?: number;\n    /**\n     * The name of the database to search for documents.\n     */\n    dbName?: string;\n    /**\n     * The prompt to the chatmodel to extract entities to perform Full text search on the database\n     */\n    promptEntityExtractor?: string;\n    /**\n     * The chatmodel to extract entities to perform Full text search on the database\n     */\n    entityExtractor?: BaseChatModel;\n    /**\n     * Max items to maintain per searchtype. Default is 3.\n     */\n    maxItemsSearch?: number;\n    /**\n     * The columns from the tables that metadata must contain\n     */\n    metadataItems?: string[];\n    /**\n     * Name of the table to perform vector similarity seach. Default is 'documents'\n     */\n    vectorTable?: string;\n    /**\n     * Name of the table to perform full text search. Default is 'document_fts'\n     */\n    ftsTable?: string;\n    /**\n     * Filters to apply to the search. Default is an empty array.\n     */\n    filters?: AzionFilter[];\n    /** Whether the metadata is contained in a single column or multiple columns */\n    expandedMetadata?: boolean;\n}\n/**\n * class for performing hybrid search operations on Azion's Edge SQL database.\n * It extends the 'BaseRetriever' class and implements methods for\n * similarity search and full-text search (FTS).\n */\n/**\n * Example usage:\n * ```ts\n * // Initialize embeddings and chat model\n * const embeddings = new OpenAIEmbeddings();\n * const chatModel = new ChatOpenAI({ model: \"gpt-4o-mini\" });\n *\n * // Create retriever with hybrid search\n * const retriever = new AzionRetriever(embeddings, chatModel, {\n *   searchType: 'hybrid',\n *   similarityK: 3,\n *   ftsK: 2,\n *   dbName: 'my_docs',\n *   metadataItems: ['category', 'author'],\n *   vectorTable: 'documents',\n *   ftsTable: 'documents_fts',\n *   filters: [\n *     { operator: '=', column: 'status', value: 'published' }\n *   ]\n * });\n *\n * // Retrieve relevant documents\n * const docs = await retriever.invoke(\n *   \"What are coral reefs in Australia?\"\n * );\n *\n * // Create retriever with similarity search only\n * const simRetriever = new AzionRetriever(embeddings, chatModel, {\n *   searchType: 'similarity',\n *   similarityK: 5,\n *   dbName: 'my_docs',\n *   vectorTable: 'documents'\n * });\n *\n * // Customize entity extraction prompt\n * const customRetriever = new AzionRetriever(embeddings, chatModel, {\n *   searchType: 'hybrid',\n *   similarityK: 3,\n *   ftsK: 2,\n *   dbName: 'my_docs',\n *   promptEntityExtractor: \"Extract key entities from: {{query}}\"\n * });\n * ```\n */\nexport declare class AzionRetriever extends BaseRetriever {\n    static lc_name(): string;\n    /** Namespace for the retriever in LangChain */\n    lc_namespace: string[];\n    /** Type of search to perform - either hybrid (combining vector + FTS) or similarity only */\n    searchType?: \"hybrid\" | \"similarity\";\n    /** Number of results to return from similarity search. Minimum is 1. */\n    similarityK: number;\n    /** Number of results to return from full text search. Minimum is 1. */\n    ftsK: number;\n    /** Interface for generating embeddings from text */\n    embeddings: EmbeddingsInterface;\n    /** Name of the database to search */\n    dbName: string;\n    /** Optional ChatModel used to extract entities from queries */\n    entityExtractor?: BaseChatModel;\n    /** Prompt template for entity extraction */\n    promptEntityExtractor: string;\n    /** Optional metadata columns to include in results */\n    metadataItems?: string[];\n    /** Name of table containing vector embeddings for similarity search */\n    vectorTable: string;\n    /** Name of table containing documents for full text search */\n    ftsTable: string;\n    /** Array of filters to apply to search results */\n    filters: AzionFilter[];\n    /** Whether the metadata is contained in a single column or multiple columns */\n    expandedMetadata: boolean;\n    constructor(embeddings: EmbeddingsInterface, args: AzionRetrieverArgs);\n    /**\n     * Generates a string of filters for the SQL query.\n     * @param {AzionFilter[]} filters - The filters to apply to the search.\n     * @returns {string} A string of filters for the SQL query.\n     */\n    protected generateFilters(filters: AzionFilter[]): string;\n    /**\n     * Generates SQL queries for full-text search and similarity search.\n     * @param {number[]} embeddedQuery - The embedded query vector.\n     * @param {string} queryEntities - The entities extracted from the query for full-text search.\n     * @param {string} metadata - Additional metadata columns to be included in the results.\n     * @returns An object containing the FTS query and similarity query strings.\n     */\n    protected generateSqlQueries(embeddedQuery: number[], queryEntities: string, metadata: string): {\n        ftsQuery: string;\n        similarityQuery: string;\n    };\n    /**\n     * Generates the SQL statements for the similarity search and full-text search.\n     * @param query The user query.\n     * @returns An array of SQL statements.\n     */\n    protected generateStatements(query: string): Promise<string[]>;\n    /**\n     * Generates the metadata string for the SQL query.\n     * @returns {string} The metadata string.\n     */\n    protected generateMetadata(): string;\n    /**\n     * Performs a similarity search on the vector store and returns the top 'similarityK' similar documents.\n     * @param query The query string.\n     * @returns A promise that resolves with the similarity search results when the search is complete.\n     */\n    protected similaritySearchWithScore(query: string): Promise<[Document][]>;\n    /**\n     * Extracts entities from a user query using the entityExtractor model.\n     * @param query The user query\n     * @returns A promise that resolves with the extracted entities when the extraction is complete.\n     */\n    protected extractEntities(query: string): Promise<string>;\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    /**\n     * Performs a hybrid search on the vector store, using cosine similarity and FTS search, and\n     * returns the top 'similarityK' + 'ftsK' similar documents.\n     * @param query The user query\n     * @returns A promise that resolves with the hybrid search results when the search is complete.\n     */\n    protected hybridSearchAzion(query: string): Promise<[Document][]>;\n    /**\n     * Generates an error document based on the provided error information\n     * @param error The error object containing details about the issue\n     * @returns A promise that resolves to an array containing a single Document representing the error\n     */\n    protected searchError(error: {\n        message: string;\n        operation: string;\n    } | undefined): Error;\n    /**\n     * Performs the selected search and returns the documents retrieved.\n     * @param query The user query\n     * @returns A promise that resolves with the completion of the search results.\n     */\n    _getRelevantDocuments(query: string): Promise<Document[]>;\n    /**\n     * Removes duplicate results from the search results, prioritizing a mix of similarity and FTS results.\n     * @param {SearchEmbeddingsResponse[]} results - The array of search results to process.\n     * @returns {SearchEmbeddingsResponse[]} An array of unique search results, with a maximum of 3 similarity and 3 FTS results.\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    protected mapSearches(searches: SearchEmbeddingsResponse[]): [Document][];\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}\nexport {};\n//# sourceMappingURL=azion_edgesql.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