@langchain/google-cloud-sql-pg 0.0.2 → 1.0.0
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 +17 -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.cts.map +1 -0
- package/dist/chat_message_history.d.ts +53 -43
- package/dist/chat_message_history.d.ts.map +1 -0
- 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.cts.map +1 -0
- package/dist/engine.d.ts +102 -80
- package/dist/engine.d.ts.map +1 -0
- 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.cts.map +1 -0
- package/dist/indexes.d.ts +50 -47
- package/dist/indexes.d.ts.map +1 -0
- 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.cts.map +1 -0
- package/dist/loader.d.ts +40 -26
- package/dist/loader.d.ts.map +1 -0
- 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.cts.map +1 -0
- package/dist/vectorstore.d.ts +147 -130
- package/dist/vectorstore.d.ts.map +1 -0
- package/dist/vectorstore.js +436 -588
- package/dist/vectorstore.js.map +1 -0
- package/package.json +38 -47
- 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/engine.d.ts
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
import { Connector, IpAddressTypes } from "@google-cloud/cloud-sql-connector";
|
|
2
2
|
import knex from "knex";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
|
|
4
|
+
//#region src/engine.d.ts
|
|
5
|
+
interface PostgresEngineArgs {
|
|
6
|
+
ipType?: IpAddressTypes;
|
|
7
|
+
user?: string;
|
|
8
|
+
password?: string;
|
|
9
|
+
iamAccountEmail?: string;
|
|
8
10
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
interface VectorStoreTableArgs {
|
|
12
|
+
schemaName?: string;
|
|
13
|
+
contentColumn?: string;
|
|
14
|
+
embeddingColumn?: string;
|
|
15
|
+
embeddingColumnType?: "vector" | "halfvec" | "bit" | "sparsevec";
|
|
16
|
+
metadataColumns?: Column[];
|
|
17
|
+
metadataJsonColumn?: string;
|
|
18
|
+
idColumn?: string | Column;
|
|
19
|
+
overwriteExisting?: boolean;
|
|
20
|
+
storeMetadata?: boolean;
|
|
18
21
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
declare class Column {
|
|
23
|
+
name: string;
|
|
24
|
+
dataType: string;
|
|
25
|
+
nullable: boolean;
|
|
26
|
+
constructor(name: string, dataType: string, nullable?: boolean);
|
|
27
|
+
private postInitilization;
|
|
25
28
|
}
|
|
26
29
|
/**
|
|
27
30
|
* Cloud SQL shared connection pool
|
|
@@ -53,64 +56,83 @@ export declare class Column {
|
|
|
53
56
|
* <br />
|
|
54
57
|
*
|
|
55
58
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
59
|
+
declare class PostgresEngine {
|
|
60
|
+
private static _createKey;
|
|
61
|
+
pool: knex.Knex;
|
|
62
|
+
static connector: Connector;
|
|
63
|
+
constructor(key: symbol, pool: knex.Knex);
|
|
64
|
+
/**
|
|
65
|
+
* @param projectId Required - GCP Project ID
|
|
66
|
+
* @param region Required - Postgres Instance Region
|
|
67
|
+
* @param instance Required - Postgres Instance name
|
|
68
|
+
* @param database Required - Database name
|
|
69
|
+
* @param ipType Optional - IP address type. Defaults to IPAddressType.PUBLIC
|
|
70
|
+
* @param user Optional - Postgres user name. Defaults to undefined
|
|
71
|
+
* @param password Optional - Postgres user password. Defaults to undefined
|
|
72
|
+
* @param iamAccountEmail Optional - IAM service account email. Defaults to undefined
|
|
73
|
+
* @returns PostgresEngine instance
|
|
74
|
+
*/
|
|
75
|
+
static fromInstance(projectId: string, region: string, instance: string, database: string, {
|
|
76
|
+
ipType,
|
|
77
|
+
user,
|
|
78
|
+
password,
|
|
79
|
+
iamAccountEmail
|
|
80
|
+
}?: PostgresEngineArgs): Promise<PostgresEngine>;
|
|
81
|
+
/**
|
|
82
|
+
* Create a PostgresEngine instance from an Knex instance.
|
|
83
|
+
*
|
|
84
|
+
* @param engine knex instance
|
|
85
|
+
* @returns PostgresEngine instance from a knex instance
|
|
86
|
+
*/
|
|
87
|
+
static fromPool(engine: knex.Knex): Promise<PostgresEngine>;
|
|
88
|
+
/**
|
|
89
|
+
* Create a PostgresEngine instance from arguments.
|
|
90
|
+
*
|
|
91
|
+
* @param url URL use to connect to a database
|
|
92
|
+
* @param poolConfig Optional - Configuration pool to use in the Knex configuration
|
|
93
|
+
* @returns PostgresEngine instance
|
|
94
|
+
*/
|
|
95
|
+
static fromConnectionString(url: string | knex.Knex.StaticConnectionConfig, poolConfig?: knex.Knex.PoolConfig): Promise<PostgresEngine>;
|
|
96
|
+
/**
|
|
97
|
+
* Create a table for saving of vectors to be used with PostgresVectorStore.
|
|
98
|
+
*
|
|
99
|
+
* @param tableName Postgres database table name. Parameter is not escaped. Do not use with end user input.
|
|
100
|
+
* @param vectorSize Vector size for the embedding model to be used.
|
|
101
|
+
* @param schemaName The schema name to store Postgres database table. Default: "public". Parameter is not escaped. Do not use with end user input.
|
|
102
|
+
* @param contentColumn Name of the column to store document content. Default: "content".
|
|
103
|
+
* @param embeddingColumn Name of the column to store vector embeddings. Default: "embedding".
|
|
104
|
+
* @param embeddingColumnType Type of the embedding column ("vector" | "halfvec" | "bit" | "sparsevec"). Default: "vector". More info on HNSW-supported types: https://github.com/pgvector/pgvector#hnsw
|
|
105
|
+
* @param metadataColumns Optional - A list of Columns to create for custom metadata. Default: [].
|
|
106
|
+
* @param metadataJsonColumn Optional - The column to store extra metadata in JSON format. Default: "langchain_metadata".
|
|
107
|
+
* @param idColumn Optional - Column to store ids. Default: "langchain_id" column name with data type UUID.
|
|
108
|
+
* @param overwriteExisting Whether to drop existing table. Default: False.
|
|
109
|
+
* @param storeMetadata Whether to store metadata in the table. Default: True.
|
|
110
|
+
*/
|
|
111
|
+
initVectorstoreTable(tableName: string, vectorSize: number, {
|
|
112
|
+
schemaName,
|
|
113
|
+
contentColumn,
|
|
114
|
+
embeddingColumn,
|
|
115
|
+
embeddingColumnType,
|
|
116
|
+
metadataColumns,
|
|
117
|
+
metadataJsonColumn,
|
|
118
|
+
idColumn,
|
|
119
|
+
overwriteExisting,
|
|
120
|
+
storeMetadata
|
|
121
|
+
}?: VectorStoreTableArgs): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* Create a Cloud SQL table to store chat history.
|
|
124
|
+
*
|
|
125
|
+
* @param tableName Table name to store chat history
|
|
126
|
+
* @param schemaName Schema name to store chat history table
|
|
127
|
+
*/
|
|
128
|
+
initChatHistoryTable(tableName: string, schemaName?: string): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Dispose of connection pool
|
|
131
|
+
*/
|
|
132
|
+
closeConnection(): Promise<void>;
|
|
133
|
+
// Just to test the connection to the database
|
|
134
|
+
testConnection(): knex.Knex.Raw<any>;
|
|
115
135
|
}
|
|
116
|
-
|
|
136
|
+
//#endregion
|
|
137
|
+
export { Column, PostgresEngine, PostgresEngineArgs, VectorStoreTableArgs };
|
|
138
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","names":["Connector","IpAddressTypes","knex","PostgresEngineArgs","VectorStoreTableArgs","Column","PostgresEngine","Knex","ipType","user","password","iamAccountEmail","Promise","StaticConnectionConfig","PoolConfig","schemaName","contentColumn","embeddingColumn","embeddingColumnType","metadataColumns","metadataJsonColumn","idColumn","overwriteExisting","storeMetadata","Raw","default"],"sources":["../src/engine.d.ts"],"sourcesContent":["import { Connector, IpAddressTypes } from \"@google-cloud/cloud-sql-connector\";\nimport knex from \"knex\";\nexport interface PostgresEngineArgs {\n ipType?: IpAddressTypes;\n user?: string;\n password?: string;\n iamAccountEmail?: string;\n}\nexport interface VectorStoreTableArgs {\n schemaName?: string;\n contentColumn?: string;\n embeddingColumn?: string;\n embeddingColumnType?: \"vector\" | \"halfvec\" | \"bit\" | \"sparsevec\";\n metadataColumns?: Column[];\n metadataJsonColumn?: string;\n idColumn?: string | Column;\n overwriteExisting?: boolean;\n storeMetadata?: boolean;\n}\nexport declare class Column {\n name: string;\n dataType: string;\n nullable: boolean;\n constructor(name: string, dataType: string, nullable?: boolean);\n private postInitilization;\n}\n/**\n * Cloud SQL shared connection pool\n *\n * Setup:\n * Install `@langchain/google-cloud-sql-pg`\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { Column, PostgresEngine, PostgresEngineArgs } from \"@langchain/google-cloud-sql-pg\";\n *\n * const pgArgs: PostgresEngineArgs = {\n * user: \"db-user\",\n * password: \"password\"\n *}\n *\n * const engine: PostgresEngine = await PostgresEngine.fromInstance(\n * \"project-id\",\n * \"region\",\n * \"instance-name\",\n * \"database-name\",\n * pgArgs\n * );\n * ```\n * </details>\n *\n * <br />\n *\n */\nexport declare class PostgresEngine {\n private static _createKey;\n pool: knex.Knex;\n static connector: Connector;\n constructor(key: symbol, pool: knex.Knex);\n /**\n * @param projectId Required - GCP Project ID\n * @param region Required - Postgres Instance Region\n * @param instance Required - Postgres Instance name\n * @param database Required - Database name\n * @param ipType Optional - IP address type. Defaults to IPAddressType.PUBLIC\n * @param user Optional - Postgres user name. Defaults to undefined\n * @param password Optional - Postgres user password. Defaults to undefined\n * @param iamAccountEmail Optional - IAM service account email. Defaults to undefined\n * @returns PostgresEngine instance\n */\n static fromInstance(projectId: string, region: string, instance: string, database: string, { ipType, user, password, iamAccountEmail }?: PostgresEngineArgs): Promise<PostgresEngine>;\n /**\n * Create a PostgresEngine instance from an Knex instance.\n *\n * @param engine knex instance\n * @returns PostgresEngine instance from a knex instance\n */\n static fromPool(engine: knex.Knex): Promise<PostgresEngine>;\n /**\n * Create a PostgresEngine instance from arguments.\n *\n * @param url URL use to connect to a database\n * @param poolConfig Optional - Configuration pool to use in the Knex configuration\n * @returns PostgresEngine instance\n */\n static fromConnectionString(url: string | knex.Knex.StaticConnectionConfig, poolConfig?: knex.Knex.PoolConfig): Promise<PostgresEngine>;\n /**\n * Create a table for saving of vectors to be used with PostgresVectorStore.\n *\n * @param tableName Postgres database table name. Parameter is not escaped. Do not use with end user input.\n * @param vectorSize Vector size for the embedding model to be used.\n * @param schemaName The schema name to store Postgres database table. Default: \"public\". Parameter is not escaped. Do not use with end user input.\n * @param contentColumn Name of the column to store document content. Default: \"content\".\n * @param embeddingColumn Name of the column to store vector embeddings. Default: \"embedding\".\n * @param embeddingColumnType Type of the embedding column (\"vector\" | \"halfvec\" | \"bit\" | \"sparsevec\"). Default: \"vector\". More info on HNSW-supported types: https://github.com/pgvector/pgvector#hnsw\n * @param metadataColumns Optional - A list of Columns to create for custom metadata. Default: [].\n * @param metadataJsonColumn Optional - The column to store extra metadata in JSON format. Default: \"langchain_metadata\".\n * @param idColumn Optional - Column to store ids. Default: \"langchain_id\" column name with data type UUID.\n * @param overwriteExisting Whether to drop existing table. Default: False.\n * @param storeMetadata Whether to store metadata in the table. Default: True.\n */\n initVectorstoreTable(tableName: string, vectorSize: number, { schemaName, contentColumn, embeddingColumn, embeddingColumnType, metadataColumns, metadataJsonColumn, idColumn, overwriteExisting, storeMetadata }?: VectorStoreTableArgs): Promise<void>;\n /**\n * Create a Cloud SQL table to store chat history.\n *\n * @param tableName Table name to store chat history\n * @param schemaName Schema name to store chat history table\n */\n initChatHistoryTable(tableName: string, schemaName?: string): Promise<void>;\n /**\n * Dispose of connection pool\n */\n closeConnection(): Promise<void>;\n // Just to test the connection to the database\n testConnection(): knex.Knex.Raw<any>;\n}\nexport default PostgresEngine;\n"],"mappings":";;;;UAEiBG,kBAAAA;WACJF;EADIE,IAAAA,CAAAA,EAAAA,MAAAA;EAMAC,QAAAA,CAAAA,EAAAA,MAAAA;EAAoB,eAAA,CAAA,EAAA,MAAA;;AAObC,UAPPD,oBAAAA,CAOOC;EAAM,UAAA,CAAA,EAAA,MAAA;EAITA,aAAM,CAAA,EAAA,MAAA;EAqCNC,eAAAA,CAAAA,EAAc,MAAA;EAAA,mBAAA,CAAA,EAAA,QAAA,GAAA,SAAA,GAAA,KAAA,GAAA,WAAA;EAAA,eAEpBC,CAAAA,EA7COF,MA6CPE,EAAAA;EAAI,kBACGP,CAAAA,EAAAA,MAAAA;EAAS,QACSO,CAAAA,EAAAA,MAAAA,GA7ChBF,MA6CgBE;EAAI,iBAYqDC,CAAAA,EAAAA,OAAAA;EAAM,aAAEC,CAAAA,EAAAA,OAAAA;;AAAgBE,cArDpGN,MAAAA,CAqDoGM;EAAe,IAAKR,EAAAA,MAAAA;EAAkB,QAAWG,EAAAA,MAAAA;EAAc,QAAtBM,EAAAA,OAAAA;EAAO,WAOxIL,CAAAA,IAAAA,EAAAA,MAAAA,EAAAA,QAAAA,EAAAA,MAAAA,EAAAA,QAAAA,CAAAA,EAAAA,OAAAA;EAAI,QAAWD,iBAAAA;;;;;;;;;;;;;;;;;;;;AAqCb;;;;;;;;;;;;cA5DdA,cAAAA;;QAEXJ,IAAAA,CAAKK;oBACOP;iCACaE,IAAAA,CAAKK;;;;;;;;;;;;;;;;;MAYqGJ,qBAAqBS,QAAQN;;;;;;;0BAO9IJ,IAAAA,CAAKK,OAAOK,QAAQN;;;;;;;;4CAQFJ,IAAAA,CAAKK,IAAAA,CAAKM,qCAAqCX,IAAAA,CAAKK,IAAAA,CAAKO,aAAaF,QAAQN;;;;;;;;;;;;;;;;;;;;;;;;;;MAgB2FF,uBAAuBQ;;;;;;;gEAO5KA;;;;qBAI3CA;;oBAEDV,IAAAA,CAAKK,IAAAA,CAAKiB"}
|