@langchain/community
Version:
Third-party integrations for LangChain.js
1 lines • 8.28 kB
Source Map (JSON)
{"version":3,"file":"vercel_postgres.d.ts","names":["VercelPool","VercelPoolClient","VercelPostgresPoolConfig","EmbeddingsInterface","VectorStore","Document","Metadata","Record","VercelPostgresFields","VercelPostgres","Partial","Promise","_neondatabase_serverless0","QueryResult"],"sources":["../../src/vectorstores/vercel_postgres.d.ts"],"sourcesContent":["import { type VercelPool, type VercelPoolClient, type VercelPostgresPoolConfig } from \"@vercel/postgres\";\nimport type { EmbeddingsInterface } from \"@langchain/core/embeddings\";\nimport { VectorStore } from \"@langchain/core/vectorstores\";\nimport { Document } from \"@langchain/core/documents\";\ntype Metadata = Record<string, string | number | Record<\"in\", string[]>>;\n/**\n * Interface that defines the arguments required to create a\n * `VercelPostgres` instance. It includes Postgres connection options,\n * table name, filter, and verbosity level.\n */\nexport interface VercelPostgresFields {\n pool: VercelPool;\n client: VercelPoolClient;\n tableName?: string;\n columns?: {\n idColumnName?: string;\n vectorColumnName?: string;\n contentColumnName?: string;\n metadataColumnName?: string;\n };\n filter?: Metadata;\n verbose?: boolean;\n}\n/**\n * Class that provides an interface to a Vercel Postgres vector database. It\n * extends the `VectorStore` base class and implements methods for adding\n * documents and vectors and performing similarity searches.\n */\nexport declare class VercelPostgres extends VectorStore {\n FilterType: Metadata;\n tableName: string;\n idColumnName: string;\n vectorColumnName: string;\n contentColumnName: string;\n metadataColumnName: string;\n filter?: Metadata;\n _verbose?: boolean;\n pool: VercelPool;\n client: VercelPoolClient;\n _vectorstoreType(): string;\n constructor(embeddings: EmbeddingsInterface, config: VercelPostgresFields);\n /**\n * Static method to create a new `VercelPostgres` instance from a\n * connection. It creates a table if one does not exist, and calls\n * `connect` to return a new instance of `VercelPostgres`.\n *\n * @param embeddings - Embeddings instance.\n * @param fields - `VercelPostgres` configuration options.\n * @returns A new instance of `VercelPostgres`.\n */\n static initialize(embeddings: EmbeddingsInterface, config?: Partial<VercelPostgresFields> & {\n postgresConnectionOptions?: VercelPostgresPoolConfig;\n }): Promise<VercelPostgres>;\n /**\n * Method to add documents to the vector store. It converts the documents into\n * vectors, and adds them to the store.\n *\n * @param documents - Array of `Document` instances.\n * @returns Promise that resolves when the documents have been added.\n */\n addDocuments(documents: Document[], options?: {\n ids?: string[];\n }): Promise<string[]>;\n /**\n * Generates the SQL placeholders for a specific row at the provided index.\n *\n * @param index - The index of the row for which placeholders need to be generated.\n * @returns The SQL placeholders for the row values.\n */\n protected generatePlaceholderForRowAt(row: (string | Record<string, any>)[], index: number): string;\n /**\n * Constructs the SQL query for inserting rows into the specified table.\n *\n * @param rows - The rows of data to be inserted, consisting of values and records.\n * @param chunkIndex - The starting index for generating query placeholders based on chunk positioning.\n * @returns The complete SQL INSERT INTO query string.\n */\n protected runInsertQuery(rows: (string | Record<string, any>)[][], useIdColumn: boolean): Promise<import(\"@neondatabase/serverless\").QueryResult<any>>;\n /**\n * Method to add vectors to the vector store. It converts the vectors into\n * rows and inserts them into the database.\n *\n * @param vectors - Array of vectors.\n * @param documents - Array of `Document` instances.\n * @returns Promise that resolves when the vectors have been added.\n */\n addVectors(vectors: number[][], documents: Document[], options?: {\n ids?: string[];\n }): Promise<string[]>;\n /**\n * Method to perform a similarity search in the vector store. It returns\n * the `k` most similar documents to the query vector, along with their\n * similarity scores.\n *\n * @param query - Query vector.\n * @param k - Number of most similar documents to return.\n * @param filter - Optional filter to apply to the search.\n * @returns Promise that resolves with an array of tuples, each containing a `Document` and its similarity score.\n */\n similaritySearchVectorWithScore(query: number[], k: number, filter?: this[\"FilterType\"]): Promise<[Document, number][]>;\n delete(params: {\n ids?: string[];\n deleteAll?: boolean;\n }): Promise<void>;\n /**\n * Method to ensure the existence of the table in the database. It creates\n * the table if it does not already exist.\n *\n * @returns Promise that resolves when the table has been ensured.\n */\n ensureTableInDatabase(): Promise<void>;\n /**\n * Static method to create a new `VercelPostgres` instance from an\n * array of texts and their metadata. It converts the texts into\n * `Document` instances and adds them to the store.\n *\n * @param texts - Array of texts.\n * @param metadatas - Array of metadata objects or a single metadata object.\n * @param embeddings - Embeddings instance.\n * @param fields - `VercelPostgres` configuration options.\n * @returns Promise that resolves with a new instance of `VercelPostgres`.\n */\n static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig?: Partial<VercelPostgresFields> & {\n postgresConnectionOptions?: VercelPostgresPoolConfig;\n }): Promise<VercelPostgres>;\n /**\n * Static method to create a new `VercelPostgres` instance from an\n * array of `Document` instances. It adds the documents to the store.\n *\n * @param docs - Array of `Document` instances.\n * @param embeddings - Embeddings instance.\n * @param fields - `VercelPostgres` configuration options.\n * @returns Promise that resolves with a new instance of `VercelPostgres`.\n */\n static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig?: Partial<VercelPostgresFields> & {\n postgresConnectionOptions?: VercelPostgresPoolConfig;\n }): Promise<VercelPostgres>;\n /**\n * Closes all the clients in the pool and terminates the pool.\n *\n * @returns Promise that resolves when all clients are closed and the pool is terminated.\n */\n end(): Promise<void>;\n}\nexport {};\n//# sourceMappingURL=vercel_postgres.d.ts.map"],"mappings":";;;;;;;KAIKM,QAAAA,GAAWC,iCAAiCA;;;AADI;AAOrD;;AAEYN,UAFKO,oBAAAA,CAELP;EAQCK,IAAAA,EATHN,UASGM;EAAQ,MAAA,EARTL,gBAQS;EAQAQ,SAAAA,CAAAA,EAAAA,MAAc;EACnBH,OAAAA,CAAAA,EAAAA;IAMHA,YAAAA,CAAAA,EAAAA,MAAAA;IAEHN,gBAAAA,CAAAA,EAAAA,MAAAA;IACEC,iBAAAA,CAAAA,EAAAA,MAAAA;IAEgBE,kBAAAA,CAAAA,EAAAA,MAAAA;EAA6BK,CAAAA;EAUvBL,MAAAA,CAAAA,EA9BrBG,QA8BqBH;EAAsCK,OAAAA,CAAAA,EAAAA,OAAAA;;;;;;;AAmBfD,cAzCpCE,cAAAA,SAAuBL,WAAAA,CAyCaG;EAQZA,UAAAA,EAhD7BD,QAgD6BC;EAAMK,SA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