@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/utils/utils.js
CHANGED
|
@@ -1,69 +1,43 @@
|
|
|
1
|
+
//#region src/utils/utils.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
-
.then((res) => res.data);
|
|
20
|
-
if (!("email" in clientResponse)) {
|
|
21
|
-
throw new Error("Failed to automatically obtain authenticated IAM principal's " +
|
|
22
|
-
"email address using environment's ADC credentials!");
|
|
23
|
-
}
|
|
24
|
-
const { email } = clientResponse;
|
|
25
|
-
return email.replace(".gserviceaccount.com", "");
|
|
3
|
+
* Get email address associated with current authenticated IAM principal.
|
|
4
|
+
* Email will be used for automatic IAM database authentication to Cloud SQL.
|
|
5
|
+
*
|
|
6
|
+
* @param {GoogleAuth} auth - object to use in finding the associated IAM principal email address.
|
|
7
|
+
* @returns {string} email - email address associated with the current authenticated IAM principal
|
|
8
|
+
*/
|
|
9
|
+
const getIAMPrincipalEmail = async (auth) => {
|
|
10
|
+
const credentials = await auth.getCredentials();
|
|
11
|
+
if ("client_email" in credentials && credentials.client_email !== void 0) return credentials.client_email.replace(".gserviceaccount.com", "");
|
|
12
|
+
const accessToken = await auth.getAccessToken();
|
|
13
|
+
const client = await auth.getClient();
|
|
14
|
+
const url = `https://oauth2.googleapis.com/tokeninfo?access_token=${accessToken}`;
|
|
15
|
+
const clientResponse = await client.request({ url }).then((res) => res.data);
|
|
16
|
+
if (!("email" in clientResponse)) throw new Error("Failed to automatically obtain authenticated IAM principal's email address using environment's ADC credentials!");
|
|
17
|
+
const { email } = clientResponse;
|
|
18
|
+
return email.replace(".gserviceaccount.com", "");
|
|
26
19
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
result.push(arrays.map((arr) => arr[i]));
|
|
33
|
-
}
|
|
34
|
-
return result;
|
|
20
|
+
const customZip = (...arrays) => {
|
|
21
|
+
const minLength = Math.min(...arrays.map((arr) => arr.length));
|
|
22
|
+
const result = [];
|
|
23
|
+
for (let i = 0; i < minLength; i += 1) result.push(arrays.map((arr) => arr[i]));
|
|
24
|
+
return result;
|
|
35
25
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*/
|
|
39
|
-
// txt document formatter.
|
|
40
|
-
export function textFormatter(row, content_columns) {
|
|
41
|
-
return content_columns
|
|
42
|
-
.filter((column) => column in row)
|
|
43
|
-
.map((column) => String(row[column]))
|
|
44
|
-
.join(" ");
|
|
26
|
+
function textFormatter(row, content_columns) {
|
|
27
|
+
return content_columns.filter((column) => column in row).map((column) => String(row[column])).join(" ");
|
|
45
28
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return content_columns
|
|
49
|
-
.filter((column) => column in row)
|
|
50
|
-
.map((column) => String(row[column]))
|
|
51
|
-
.join(", ");
|
|
29
|
+
function csvFormatter(row, content_columns) {
|
|
30
|
+
return content_columns.filter((column) => column in row).map((column) => String(row[column])).join(", ");
|
|
52
31
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return content_columns
|
|
56
|
-
.filter((column) => column in row)
|
|
57
|
-
.map((column) => `${column}: ${String(row[column])}`)
|
|
58
|
-
.join("\n");
|
|
32
|
+
function yamlFormatter(row, content_columns) {
|
|
33
|
+
return content_columns.filter((column) => column in row).map((column) => `${column}: ${String(row[column])}`).join("\n");
|
|
59
34
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (column in row) {
|
|
65
|
-
dictionary[column] = row[column];
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return JSON.stringify(dictionary);
|
|
35
|
+
function jsonFormatter(row, content_columns) {
|
|
36
|
+
const dictionary = {};
|
|
37
|
+
for (const column of content_columns) if (column in row) dictionary[column] = row[column];
|
|
38
|
+
return JSON.stringify(dictionary);
|
|
69
39
|
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { csvFormatter, customZip, getIAMPrincipalEmail, jsonFormatter, textFormatter, yamlFormatter };
|
|
43
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["auth: GoogleAuth","res: { data: any }","row: { [key: string]: string }","content_columns: string[]","dictionary: { [key: string]: string }"],"sources":["../../src/utils/utils.ts"],"sourcesContent":["import { GoogleAuth } from \"google-auth-library\";\n\n/**\n * Get email address associated with current authenticated IAM principal.\n * Email will be used for automatic IAM database authentication to Cloud SQL.\n *\n * @param {GoogleAuth} auth - object to use in finding the associated IAM principal email address.\n * @returns {string} email - email address associated with the current authenticated IAM principal\n */\nexport const getIAMPrincipalEmail = async (\n auth: GoogleAuth\n): Promise<string> => {\n const credentials = await auth.getCredentials();\n\n if (\"client_email\" in credentials && credentials.client_email !== undefined) {\n return credentials.client_email.replace(\".gserviceaccount.com\", \"\");\n }\n\n const accessToken = await auth.getAccessToken();\n const client = await auth.getClient();\n\n const url = `https://oauth2.googleapis.com/tokeninfo?access_token=${accessToken}`;\n const clientResponse = await client\n .request({ url })\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .then((res: { data: any }) => res.data);\n\n if (!(\"email\" in clientResponse)) {\n throw new Error(\n \"Failed to automatically obtain authenticated IAM principal's \" +\n \"email address using environment's ADC credentials!\"\n );\n }\n const { email } = clientResponse;\n return email.replace(\".gserviceaccount.com\", \"\");\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const customZip = (...arrays: any[]) => {\n const minLength = Math.min(...arrays.map((arr) => arr.length));\n const result = [];\n for (let i = 0; i < minLength; i += 1) {\n result.push(arrays.map((arr) => arr[i]));\n }\n return result;\n};\n\n/*\n Formatter functions\n*/\n\n// txt document formatter.\nexport function textFormatter(\n row: { [key: string]: string },\n content_columns: string[]\n): string {\n return content_columns\n .filter((column) => column in row)\n .map((column) => String(row[column]))\n .join(\" \");\n}\n\n// CSV document formatter.\nexport function csvFormatter(\n row: { [key: string]: string },\n content_columns: string[]\n): string {\n return content_columns\n .filter((column) => column in row)\n .map((column) => String(row[column]))\n .join(\", \");\n}\n\n// YAML document formatter\nexport function yamlFormatter(\n row: { [key: string]: string },\n content_columns: string[]\n): string {\n return content_columns\n .filter((column) => column in row)\n .map((column) => `${column}: ${String(row[column])}`)\n .join(\"\\n\");\n}\n\n// JSON document formatter\nexport function jsonFormatter(\n row: { [key: string]: string },\n content_columns: string[]\n): string {\n const dictionary: { [key: string]: string } = {};\n for (const column of content_columns) {\n if (column in row) {\n dictionary[column] = row[column];\n }\n }\n return JSON.stringify(dictionary);\n}\n"],"mappings":";;;;;;;;AASA,MAAa,uBAAuB,OAClCA,SACoB;CACpB,MAAM,cAAc,MAAM,KAAK,gBAAgB;AAE/C,KAAI,kBAAkB,eAAe,YAAY,iBAAiB,OAChE,QAAO,YAAY,aAAa,QAAQ,wBAAwB,GAAG;CAGrE,MAAM,cAAc,MAAM,KAAK,gBAAgB;CAC/C,MAAM,SAAS,MAAM,KAAK,WAAW;CAErC,MAAM,MAAM,CAAC,qDAAqD,EAAE,aAAa;CACjF,MAAM,iBAAiB,MAAM,OAC1B,QAAQ,EAAE,IAAK,EAAC,CAEhB,KAAK,CAACC,QAAuB,IAAI,KAAK;AAEzC,KAAI,EAAE,WAAW,gBACf,OAAM,IAAI,MACR;CAIJ,MAAM,EAAE,OAAO,GAAG;AAClB,QAAO,MAAM,QAAQ,wBAAwB,GAAG;AACjD;AAGD,MAAa,YAAY,CAAC,GAAG,WAAkB;CAC7C,MAAM,YAAY,KAAK,IAAI,GAAG,OAAO,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC;CAC9D,MAAM,SAAS,CAAE;AACjB,MAAK,IAAI,IAAI,GAAG,IAAI,WA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