@langchain/google-cloud-sql-pg 0.0.2 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/LICENSE +6 -6
- package/README.md +1 -1
- package/dist/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/chat_message_history.cjs +104 -137
- package/dist/chat_message_history.cjs.map +1 -0
- package/dist/chat_message_history.d.cts +57 -0
- package/dist/chat_message_history.d.ts +53 -43
- package/dist/chat_message_history.js +103 -133
- package/dist/chat_message_history.js.map +1 -0
- package/dist/engine.cjs +188 -242
- package/dist/engine.cjs.map +1 -0
- package/dist/engine.d.cts +138 -0
- package/dist/engine.d.ts +102 -80
- package/dist/engine.js +186 -234
- package/dist/engine.js.map +1 -0
- package/dist/index.cjs +21 -20
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +7 -4
- package/dist/indexes.cjs +96 -168
- package/dist/indexes.cjs.map +1 -0
- package/dist/indexes.d.cts +68 -0
- package/dist/indexes.d.ts +50 -47
- package/dist/indexes.js +90 -161
- package/dist/indexes.js.map +1 -0
- package/dist/loader.cjs +159 -242
- package/dist/loader.cjs.map +1 -0
- package/dist/loader.d.cts +101 -0
- package/dist/loader.d.ts +40 -26
- package/dist/loader.js +157 -237
- package/dist/loader.js.map +1 -0
- package/dist/utils/utils.cjs +36 -65
- package/dist/utils/utils.cjs.map +1 -0
- package/dist/utils/utils.js +36 -62
- package/dist/utils/utils.js.map +1 -0
- package/dist/vectorstore.cjs +438 -593
- package/dist/vectorstore.cjs.map +1 -0
- package/dist/vectorstore.d.cts +300 -0
- package/dist/vectorstore.d.ts +147 -130
- package/dist/vectorstore.js +436 -588
- package/dist/vectorstore.js.map +1 -0
- package/package.json +41 -48
- package/dist/utils/utils.d.ts +0 -22
- package/index.cjs +0 -1
- package/index.d.cts +0 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
package/dist/vectorstore.d.ts
CHANGED
|
@@ -1,41 +1,43 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PostgresEngine } from "./engine.js";
|
|
2
|
+
import { BaseIndex, DistanceStrategy, QueryOptions } from "./indexes.js";
|
|
2
3
|
import { MaxMarginalRelevanceSearchOptions, VectorStore } from "@langchain/core/vectorstores";
|
|
3
4
|
import { Document } from "@langchain/core/documents";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
import { EmbeddingsInterface } from "@langchain/core/embeddings";
|
|
6
|
+
|
|
7
|
+
//#region src/vectorstore.d.ts
|
|
8
|
+
interface PostgresVectorStoreArgs {
|
|
9
|
+
schemaName?: string;
|
|
10
|
+
contentColumn?: string;
|
|
11
|
+
embeddingColumn?: string;
|
|
12
|
+
metadataColumns?: Array<string>;
|
|
13
|
+
idColumn?: string;
|
|
14
|
+
distanceStrategy?: DistanceStrategy;
|
|
15
|
+
k?: number;
|
|
16
|
+
fetchK?: number;
|
|
17
|
+
lambdaMult?: number;
|
|
18
|
+
ignoreMetadataColumns?: Array<string>;
|
|
19
|
+
metadataJsonColumn?: string;
|
|
20
|
+
indexQueryOptions?: QueryOptions;
|
|
19
21
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
interface dbConfigArgs {
|
|
23
|
+
engine: PostgresEngine;
|
|
24
|
+
tableName: string;
|
|
25
|
+
dbConfig?: PostgresVectorStoreArgs;
|
|
24
26
|
}
|
|
25
27
|
interface VSArgs {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
engine: PostgresEngine;
|
|
29
|
+
tableName: string;
|
|
30
|
+
schemaName: string;
|
|
31
|
+
contentColumn: string;
|
|
32
|
+
embeddingColumn: string;
|
|
33
|
+
metadataColumns: Array<string>;
|
|
34
|
+
idColumn: string;
|
|
35
|
+
distanceStrategy: DistanceStrategy;
|
|
36
|
+
k: number;
|
|
37
|
+
fetchK: number;
|
|
38
|
+
lambdaMult: number;
|
|
39
|
+
metadataJsonColumn: string;
|
|
40
|
+
indexQueryOptions?: QueryOptions;
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
41
43
|
* Google Cloud SQL for PostgreSQL vector store integration.
|
|
@@ -183,101 +185,116 @@ interface VSArgs {
|
|
|
183
185
|
*
|
|
184
186
|
* <br />
|
|
185
187
|
*/
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
188
|
+
declare class PostgresVectorStore extends VectorStore {
|
|
189
|
+
FilterType: string;
|
|
190
|
+
engine: PostgresEngine;
|
|
191
|
+
embeddings: EmbeddingsInterface;
|
|
192
|
+
tableName: string;
|
|
193
|
+
schemaName: string;
|
|
194
|
+
contentColumn: string;
|
|
195
|
+
embeddingColumn: string;
|
|
196
|
+
metadataColumns: Array<string>;
|
|
197
|
+
idColumn: string;
|
|
198
|
+
metadataJsonColumn: string;
|
|
199
|
+
distanceStrategy: DistanceStrategy;
|
|
200
|
+
k: number;
|
|
201
|
+
fetchK: number;
|
|
202
|
+
lambdaMult: number;
|
|
203
|
+
indexQueryOptions: QueryOptions | undefined;
|
|
204
|
+
/**
|
|
205
|
+
* Initializes a new vector store with embeddings and database configuration.
|
|
206
|
+
*
|
|
207
|
+
* @param embeddings - Instance of `EmbeddingsInterface` used to embed queries.
|
|
208
|
+
* @param dbConfig - Configuration settings for the database or storage system.
|
|
209
|
+
*/
|
|
210
|
+
constructor(embeddings: EmbeddingsInterface, dbConfig: VSArgs);
|
|
211
|
+
/**
|
|
212
|
+
* Create a new PostgresVectorStore instance.
|
|
213
|
+
* @param {PostgresEngine} engine Required - Connection pool engine for managing connections to Cloud SQL for PostgreSQL database.
|
|
214
|
+
* @param {Embeddings} embeddings Required - Text embedding model to use.
|
|
215
|
+
* @param {string} tableName Required - Name of an existing table or table to be created.
|
|
216
|
+
* @param {string} schemaName Database schema name of the table. Defaults to "public".
|
|
217
|
+
* @param {string} contentColumn Column that represent a Document's page_content. Defaults to "content".
|
|
218
|
+
* @param {string} embeddingColumn Column for embedding vectors. The embedding is generated from the document value. Defaults to "embedding".
|
|
219
|
+
* @param {Array<string>} metadataColumns Column(s) that represent a document's metadata.
|
|
220
|
+
* @param {Array<string>} ignoreMetadataColumns Optional - Column(s) to ignore in pre-existing tables for a document's metadata. Can not be used with metadata_columns.
|
|
221
|
+
* @param {string} idColumn Column that represents the Document's id. Defaults to "langchain_id".
|
|
222
|
+
* @param {string} metadataJsonColumn Optional - Column to store metadata as JSON. Defaults to "langchain_metadata".
|
|
223
|
+
* @param {DistanceStrategy} distanceStrategy Distance strategy to use for vector similarity search. Defaults to COSINE_DISTANCE.
|
|
224
|
+
* @param {number} k Number of Documents to return from search. Defaults to 4.
|
|
225
|
+
* @param {number} fetchK Number of Documents to fetch to pass to MMR algorithm.
|
|
226
|
+
* @param {number} lambdaMult Number between 0 and 1 that determines the degree of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity. Defaults to 0.5.
|
|
227
|
+
* @param {QueryOptions} indexQueryOptions Optional - Index query option.
|
|
228
|
+
* @returns PostgresVectorStore instance.
|
|
229
|
+
*/
|
|
230
|
+
static initialize(engine: PostgresEngine, embeddings: EmbeddingsInterface, tableName: string, {
|
|
231
|
+
schemaName,
|
|
232
|
+
contentColumn,
|
|
233
|
+
embeddingColumn,
|
|
234
|
+
metadataColumns,
|
|
235
|
+
ignoreMetadataColumns,
|
|
236
|
+
idColumn,
|
|
237
|
+
metadataJsonColumn,
|
|
238
|
+
distanceStrategy,
|
|
239
|
+
k,
|
|
240
|
+
fetchK,
|
|
241
|
+
lambdaMult,
|
|
242
|
+
indexQueryOptions
|
|
243
|
+
}?: PostgresVectorStoreArgs): Promise<PostgresVectorStore>;
|
|
244
|
+
static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig: dbConfigArgs): Promise<VectorStore>;
|
|
245
|
+
static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig: dbConfigArgs): Promise<VectorStore>;
|
|
246
|
+
addVectors(vectors: number[][], documents: Document[], options?: {
|
|
247
|
+
ids?: string[];
|
|
248
|
+
}): Promise<string[] | void>;
|
|
249
|
+
_vectorstoreType(): string;
|
|
250
|
+
/**
|
|
251
|
+
* Adds documents to the vector store, embedding them first through the
|
|
252
|
+
* `embeddings` instance.
|
|
253
|
+
*
|
|
254
|
+
* @param documents - Array of documents to embed and add.
|
|
255
|
+
* @param options - Optional configuration for embedding and storing documents.
|
|
256
|
+
* @returns A promise resolving to an array of document IDs or void, based on implementation.
|
|
257
|
+
* @abstract
|
|
258
|
+
*/
|
|
259
|
+
addDocuments(documents: Document[], options?: {
|
|
260
|
+
ids?: string[];
|
|
261
|
+
}): Promise<string[] | void>;
|
|
262
|
+
/**
|
|
263
|
+
* Deletes documents from the vector store based on the specified ids.
|
|
264
|
+
*
|
|
265
|
+
* @param params - Flexible key-value pairs defining conditions for document deletion.
|
|
266
|
+
* @param ids - Optional: Property of {params} that contains the array of ids to be deleted
|
|
267
|
+
* @returns A promise that resolves once the deletion is complete.
|
|
268
|
+
*/
|
|
269
|
+
delete(params: {
|
|
270
|
+
ids?: string[];
|
|
271
|
+
}): Promise<void>;
|
|
272
|
+
similaritySearchVectorWithScore(embedding: number[], k: number, filter?: this["FilterType"]): Promise<[Document, number][]>;
|
|
273
|
+
private queryCollection;
|
|
274
|
+
maxMarginalRelevanceSearch(query: string, options: MaxMarginalRelevanceSearchOptions<this["FilterType"]>): Promise<Document[]>;
|
|
275
|
+
/**
|
|
276
|
+
* Create an index on the vector store table
|
|
277
|
+
* @param {BaseIndex} index
|
|
278
|
+
* @param {string} name Optional
|
|
279
|
+
* @param {boolean} concurrently Optional
|
|
280
|
+
*/
|
|
281
|
+
applyVectorIndex(index: BaseIndex, name?: string, concurrently?: boolean): Promise<void>;
|
|
282
|
+
/**
|
|
283
|
+
* Check if index exists in the table.
|
|
284
|
+
* @param {string} indexName Optional - index name
|
|
285
|
+
*/
|
|
286
|
+
isValidIndex(indexName?: string): Promise<boolean>;
|
|
287
|
+
/**
|
|
288
|
+
* Drop the vector index
|
|
289
|
+
* @param {string} indexName Optional - index name
|
|
290
|
+
*/
|
|
291
|
+
dropVectorIndex(indexName?: string): Promise<void>;
|
|
292
|
+
/**
|
|
293
|
+
* Re-index the vector store table
|
|
294
|
+
* @param {string} indexName Optional - index name
|
|
295
|
+
*/
|
|
296
|
+
reIndex(indexName?: string): Promise<void>;
|
|
282
297
|
}
|
|
283
|
-
|
|
298
|
+
//#endregion
|
|
299
|
+
export { PostgresVectorStore, PostgresVectorStoreArgs, dbConfigArgs };
|
|
300
|
+
//# sourceMappingURL=vectorstore.d.ts.map
|