{"version":3,"file":"supabase.d.ts","names":["SupabaseClient","PostgrestFilterBuilder","MaxMarginalRelevanceSearchOptions","VectorStore","EmbeddingsInterface","Document","SupabaseMetadata","Record","SupabaseFilter","SupabaseFilterRPCCall","SearchEmbeddingsResponse","SupabaseLibArgs","SupabaseVectorStore","Promise"],"sources":["../../src/vectorstores/supabase.d.ts"],"sourcesContent":["import type { SupabaseClient } from \"@supabase/supabase-js\";\nimport type { PostgrestFilterBuilder } from \"@supabase/postgrest-js\";\nimport { MaxMarginalRelevanceSearchOptions, VectorStore } from \"@langchain/core/vectorstores\";\nimport type { EmbeddingsInterface } from \"@langchain/core/embeddings\";\nimport { Document } from \"@langchain/core/documents\";\nexport type SupabaseMetadata = Record<string, any>;\nexport type SupabaseFilter = PostgrestFilterBuilder<any, any, any>;\nexport type SupabaseFilterRPCCall = (rpcCall: SupabaseFilter) => SupabaseFilter;\n/**\n * Interface for the response returned when searching embeddings.\n */\ninterface SearchEmbeddingsResponse {\n    id: number;\n    content: string;\n    metadata: object;\n    embedding: number[];\n    similarity: number;\n}\n/**\n * Interface for the arguments required to initialize a Supabase library.\n */\nexport interface SupabaseLibArgs {\n    client: SupabaseClient;\n    tableName?: string;\n    queryName?: string;\n    filter?: SupabaseMetadata | SupabaseFilterRPCCall;\n    upsertBatchSize?: number;\n}\n/**\n * Supabase vector store integration.\n *\n * Setup:\n * Install `@langchain/community` and `@supabase/supabase-js`.\n *\n * ```bash\n * npm install @langchain/community @supabase/supabase-js\n * ```\n *\n * See https://js.langchain.com/docs/integrations/vectorstores/supabase for\n * instructions on how to set up your Supabase instance.\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/_langchain_community.vectorstores_supabase.SupabaseVectorStore.html#constructor)\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { SupabaseVectorStore } from \"@langchain/community/vectorstores/supabase\";\n * import { OpenAIEmbeddings } from \"@langchain/openai\";\n *\n * import { createClient } from \"@supabase/supabase-js\";\n *\n * const embeddings = new OpenAIEmbeddings({\n *   model: \"text-embedding-3-small\",\n * });\n *\n * const supabaseClient = createClient(\n *   process.env.SUPABASE_URL,\n *   process.env.SUPABASE_PRIVATE_KEY\n * );\n *\n * const vectorStore = new SupabaseVectorStore(embeddings, {\n *   client: supabaseClient,\n *   tableName: \"documents\",\n *   queryName: \"match_documents\",\n * });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Add documents</strong></summary>\n *\n * ```typescript\n * import type { Document } from '@langchain/core/documents';\n *\n * const document1 = { pageContent: \"foo\", metadata: { baz: \"bar\" } };\n * const document2 = { pageContent: \"thud\", metadata: { bar: \"baz\" } };\n * const document3 = { pageContent: \"i will be deleted :(\", metadata: {} };\n *\n * const documents: Document[] = [document1, document2, document3];\n * const ids = [\"1\", \"2\", \"3\"];\n * await vectorStore.addDocuments(documents, { ids });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Delete documents</strong></summary>\n *\n * ```typescript\n * await vectorStore.delete({ ids: [\"3\"] });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Similarity search</strong></summary>\n *\n * ```typescript\n * const results = await vectorStore.similaritySearch(\"thud\", 1);\n * for (const doc of results) {\n *   console.log(`* ${doc.pageContent} [${JSON.stringify(doc.metadata, null)}]`);\n * }\n * // Output: * thud [{\"baz\":\"bar\"}]\n * ```\n * </details>\n *\n * <br />\n *\n *\n * <details>\n * <summary><strong>Similarity search with filter</strong></summary>\n *\n * ```typescript\n * const resultsWithFilter = await vectorStore.similaritySearch(\"thud\", 1, { baz: \"bar\" });\n *\n * for (const doc of resultsWithFilter) {\n *   console.log(`* ${doc.pageContent} [${JSON.stringify(doc.metadata, null)}]`);\n * }\n * // Output: * foo [{\"baz\":\"bar\"}]\n * ```\n * </details>\n *\n * <br />\n *\n *\n * <details>\n * <summary><strong>Similarity search with score</strong></summary>\n *\n * ```typescript\n * const resultsWithScore = await vectorStore.similaritySearchWithScore(\"qux\", 1);\n * for (const [doc, score] of resultsWithScore) {\n *   console.log(`* [SIM=${score.toFixed(6)}] ${doc.pageContent} [${JSON.stringify(doc.metadata, null)}]`);\n * }\n * // Output: * [SIM=0.000000] qux [{\"bar\":\"baz\",\"baz\":\"bar\"}]\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>As a retriever</strong></summary>\n *\n * ```typescript\n * const retriever = vectorStore.asRetriever({\n *   searchType: \"mmr\", // Leave blank for standard similarity search\n *   k: 1,\n * });\n * const resultAsRetriever = await retriever.invoke(\"thud\");\n * console.log(resultAsRetriever);\n *\n * // Output: [Document({ metadata: { \"baz\":\"bar\" }, pageContent: \"thud\" })]\n * ```\n * </details>\n *\n * <br />\n */\nexport declare class SupabaseVectorStore extends VectorStore {\n    FilterType: SupabaseMetadata | SupabaseFilterRPCCall;\n    client: SupabaseClient;\n    tableName: string;\n    queryName: string;\n    filter?: SupabaseMetadata | SupabaseFilterRPCCall;\n    upsertBatchSize: number;\n    _vectorstoreType(): string;\n    constructor(embeddings: EmbeddingsInterface, args: SupabaseLibArgs);\n    /**\n     * Adds documents to the vector store.\n     * @param documents The documents to add.\n     * @param options Optional parameters for adding the documents.\n     * @returns A promise that resolves when the documents have been added.\n     */\n    addDocuments(documents: Document[], options?: {\n        ids?: string[] | number[];\n    }): Promise<string[]>;\n    /**\n     * Adds vectors to the vector store.\n     * @param vectors The vectors to add.\n     * @param documents The documents associated with the vectors.\n     * @param 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[], options?: {\n        ids?: string[] | number[];\n    }): Promise<string[]>;\n    /**\n     * Deletes vectors from the vector store.\n     * @param params The parameters for deleting vectors.\n     * @returns A promise that resolves when the vectors have been deleted.\n     */\n    delete(params: {\n        ids: string[] | number[];\n    }): Promise<void>;\n    protected _searchSupabase(query: number[], k: number, filter?: this[\"FilterType\"]): Promise<SearchEmbeddingsResponse[]>;\n    /**\n     * Performs a similarity search on the vector store.\n     * @param query The query vector.\n     * @param k The number of results to return.\n     * @param filter Optional filter to apply to the search.\n     * @returns A promise that resolves with the search results when the search is complete.\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 diversity\n     * among selected documents.\n     *\n     * @param {string} query - Text to look up documents similar to.\n     * @param {number} options.k - Number of documents to return.\n     * @param {number} options.fetchK=20- Number of documents to fetch before passing to the MMR algorithm.\n     * @param {number} options.lambda=0.5 - Number between 0 and 1 that determines the degree of diversity among the results,\n     *                 where 0 corresponds to maximum diversity and 1 to minimum diversity.\n     * @param {SupabaseLibArgs} options.filter - Optional filter to apply to the search.\n     *\n     * @returns {Promise<Document[]>} - List of documents selected by maximal marginal relevance.\n     */\n    maxMarginalRelevanceSearch(query: string, options: MaxMarginalRelevanceSearchOptions<this[\"FilterType\"]>): Promise<Document[]>;\n    /**\n     * Creates a new SupabaseVectorStore instance from an array of texts.\n     * @param texts The texts to create documents from.\n     * @param metadatas The metadata for the documents.\n     * @param embeddings The embeddings to use.\n     * @param dbConfig The configuration for the Supabase database.\n     * @returns A promise that resolves with a new SupabaseVectorStore instance when the instance has been created.\n     */\n    static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig: SupabaseLibArgs): Promise<SupabaseVectorStore>;\n    /**\n     * Creates a new SupabaseVectorStore instance from an array of documents.\n     * @param docs The documents to create the instance from.\n     * @param embeddings The embeddings to use.\n     * @param dbConfig The configuration for the Supabase database.\n     * @returns A promise that resolves with a new SupabaseVectorStore instance when the instance has been created.\n     */\n    static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig: SupabaseLibArgs): Promise<SupabaseVectorStore>;\n    /**\n     * Creates a new SupabaseVectorStore instance from an existing index.\n     * @param embeddings The embeddings to use.\n     * @param dbConfig The configuration for the Supabase database.\n     * @returns A promise that resolves with a new SupabaseVectorStore instance when the instance has been created.\n     */\n    static fromExistingIndex(embeddings: EmbeddingsInterface, dbConfig: SupabaseLibArgs): Promise<SupabaseVectorStore>;\n}\nexport {};\n//# sourceMappingURL=supabase.d.ts.map"],"mappings":";;;;;;;KAKYM,gBAAAA,GAAmBC;KACnBC,cAAAA,GAAiBP;AADjBK,KAEAG,qBAAAA,GAFmBF,CAAAA,OAAM,EAESC,cAFT,EAAA,GAE4BA,cAF5B;AACrC;AACA;AAAgF;AAchF,UAVUE,wBAAAA,CAUsB;EACpBV,EAAAA,EAAAA,MAAAA;EAGCM,OAAAA,EAAAA,MAAAA;EAAmBG,QAAAA,EAAAA,MAAAA;EAAqB,SAAA,EAAA,MAAA,EAAA;EAwIhCG,UAAAA,EAAAA,MAAAA;;;;;AAKWH,UAjJfE,eAAAA,CAiJeF;EAGJL,MAAAA,EAnJhBJ,cAmJgBI;EAA2BO,SAAAA,CAAAA,EAAAA,MAAAA;EAO3BN,SAAAA,CAAAA,EAAAA,MAAAA;EAEpBQ,MAAAA,CAAAA,EAzJKP,gBAyJLO,GAzJwBJ,qBAyJxBI;EAQuCR,eAAAA,CAAAA,EAAAA,MAAAA;;;;;;;;;;;;;;;;;;;;;;;;AAzBa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAvCO,mBAAAA,SAA4BT,WAAAA;cACjCG,mBAAmBG;UACvBT;;;WAGCM,mBAAmBG;;;0BAGJL,2BAA2BO;;;;;;;0BAO3BN;;MAEpBQ;;;;;;;;6CAQuCR;;MAEvCQ;;;;;;;;MAQAA;sFACgFA,QAAQH;;;;;;;;4FAQFG,SAASR;;;;;;;;;;;;;;;qDAehDH,wDAAwDW,QAAQR;;;;;;;;;8EASvCD,+BAA+BO,kBAAkBE,QAAQD;;;;;;;;6BAQ1GP,wBAAwBD,+BAA+BO,kBAAkBE,QAAQD;;;;;;;uCAOvER,+BAA+BO,kBAAkBE,QAAQD"}