@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.
Files changed (58) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +6 -6
  3. package/README.md +1 -1
  4. package/dist/_virtual/rolldown_runtime.cjs +25 -0
  5. package/dist/chat_message_history.cjs +104 -137
  6. package/dist/chat_message_history.cjs.map +1 -0
  7. package/dist/chat_message_history.d.cts +57 -0
  8. package/dist/chat_message_history.d.cts.map +1 -0
  9. package/dist/chat_message_history.d.ts +53 -43
  10. package/dist/chat_message_history.d.ts.map +1 -0
  11. package/dist/chat_message_history.js +103 -133
  12. package/dist/chat_message_history.js.map +1 -0
  13. package/dist/engine.cjs +188 -242
  14. package/dist/engine.cjs.map +1 -0
  15. package/dist/engine.d.cts +138 -0
  16. package/dist/engine.d.cts.map +1 -0
  17. package/dist/engine.d.ts +102 -80
  18. package/dist/engine.d.ts.map +1 -0
  19. package/dist/engine.js +186 -234
  20. package/dist/engine.js.map +1 -0
  21. package/dist/index.cjs +21 -20
  22. package/dist/index.d.cts +6 -0
  23. package/dist/index.d.ts +6 -4
  24. package/dist/index.js +7 -4
  25. package/dist/indexes.cjs +96 -168
  26. package/dist/indexes.cjs.map +1 -0
  27. package/dist/indexes.d.cts +68 -0
  28. package/dist/indexes.d.cts.map +1 -0
  29. package/dist/indexes.d.ts +50 -47
  30. package/dist/indexes.d.ts.map +1 -0
  31. package/dist/indexes.js +90 -161
  32. package/dist/indexes.js.map +1 -0
  33. package/dist/loader.cjs +159 -242
  34. package/dist/loader.cjs.map +1 -0
  35. package/dist/loader.d.cts +101 -0
  36. package/dist/loader.d.cts.map +1 -0
  37. package/dist/loader.d.ts +40 -26
  38. package/dist/loader.d.ts.map +1 -0
  39. package/dist/loader.js +157 -237
  40. package/dist/loader.js.map +1 -0
  41. package/dist/utils/utils.cjs +36 -65
  42. package/dist/utils/utils.cjs.map +1 -0
  43. package/dist/utils/utils.js +36 -62
  44. package/dist/utils/utils.js.map +1 -0
  45. package/dist/vectorstore.cjs +438 -593
  46. package/dist/vectorstore.cjs.map +1 -0
  47. package/dist/vectorstore.d.cts +300 -0
  48. package/dist/vectorstore.d.cts.map +1 -0
  49. package/dist/vectorstore.d.ts +147 -130
  50. package/dist/vectorstore.d.ts.map +1 -0
  51. package/dist/vectorstore.js +436 -588
  52. package/dist/vectorstore.js.map +1 -0
  53. package/package.json +38 -47
  54. package/dist/utils/utils.d.ts +0 -22
  55. package/index.cjs +0 -1
  56. package/index.d.cts +0 -1
  57. package/index.d.ts +0 -1
  58. package/index.js +0 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # @langchain/google-cloud-sql-pg
2
+
3
+ ## 1.0.0
4
+
5
+ This release updates the package for compatibility with LangChain v1.0. See the v1.0 [release notes](https://docs.langchain.com/oss/javascript/releases/langchain-v1) for details on what's new.
6
+
7
+ ## 0.0.2
8
+
9
+ ### Patch Changes
10
+
11
+ - cae3674: properly handle explicit metadata columns in PostgresVectorStore (#8334)
12
+ - Updated dependencies [41bd944]
13
+ - Updated dependencies [e90bc0a]
14
+ - Updated dependencies [3a99a40]
15
+ - Updated dependencies [58e9522]
16
+ - Updated dependencies [e44dc1b]
17
+ - @langchain/core@0.3.76
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- The MIT License
1
+ MIT License
2
2
 
3
- Copyright (c) 2023 LangChain
3
+ Copyright (c) LangChain, Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
9
  copies of the Software, and to permit persons to whom the Software is
10
10
  furnished to do so, subject to the following conditions:
11
11
 
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
14
 
15
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -18,7 +18,7 @@ In order to use this package, you first need to go through the following steps:
18
18
  ### Installation
19
19
 
20
20
  ```bash
21
- $ yarn add @langchain/google-cloud-sql-pg
21
+ $ pnpm install @langchain/google-cloud-sql-pg
22
22
  ```
23
23
 
24
24
  ## Example usage
@@ -0,0 +1,25 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+
25
+ exports.__toESM = __toESM;
@@ -1,72 +1,47 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PostgresChatMessageHistory = void 0;
4
- const chat_history_1 = require("@langchain/core/chat_history");
5
- const messages_1 = require("@langchain/core/messages");
6
- class PostgresChatMessageHistory extends chat_history_1.BaseChatMessageHistory {
7
- constructor({ engine, sessionId, tableName, schemaName = "public", }) {
8
- super();
9
- Object.defineProperty(this, "lc_namespace", {
10
- enumerable: true,
11
- configurable: true,
12
- writable: true,
13
- value: [
14
- "langchain",
15
- "stores",
16
- "message",
17
- "google-cloud-sql-pg",
18
- ]
19
- });
20
- Object.defineProperty(this, "engine", {
21
- enumerable: true,
22
- configurable: true,
23
- writable: true,
24
- value: void 0
25
- });
26
- Object.defineProperty(this, "sessionId", {
27
- enumerable: true,
28
- configurable: true,
29
- writable: true,
30
- value: void 0
31
- });
32
- Object.defineProperty(this, "tableName", {
33
- enumerable: true,
34
- configurable: true,
35
- writable: true,
36
- value: void 0
37
- });
38
- Object.defineProperty(this, "schemaName", {
39
- enumerable: true,
40
- configurable: true,
41
- writable: true,
42
- value: void 0
43
- });
44
- this.engine = engine;
45
- this.sessionId = sessionId;
46
- this.tableName = tableName;
47
- this.schemaName = schemaName;
48
- }
49
- /**
50
- * Create a new PostgresChatMessageHistory instance.
51
- *
52
- * @param {PostgresEngine} engine Postgres engine instance to use.
53
- * @param {string} sessionId Retrieve the table content with this session ID.
54
- * @param {string} tableName Table name that stores that chat message history. Parameter is not escaped. Do not use with end user input.
55
- * @param {string} schemaName Schema name for the chat message history table. Default: "public". Parameter is not escaped. Do not use with end user input.
56
- * @returns PostgresChatMessageHistory instance.
57
- */
58
- static async initialize(engine, sessionId, tableName, schemaName = "public") {
59
- const query = `SELECT column_name, data_type FROM information_schema.columns WHERE table_name = '${tableName}' AND table_schema = '${schemaName}'`;
60
- const { rows } = await engine.pool.raw(query);
61
- const columnNames = [];
62
- for (const index in rows) {
63
- if (Object.prototype.hasOwnProperty.call(rows, index)) {
64
- columnNames.push(rows[index].column_name);
65
- }
66
- }
67
- const requiredColumns = ["id", "session_id", "data", "type"];
68
- if (!requiredColumns.every((x) => columnNames.includes(x))) {
69
- throw new Error(`Table '${schemaName}'.'${tableName}' has incorrect schema.
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const __langchain_core_chat_history = require_rolldown_runtime.__toESM(require("@langchain/core/chat_history"));
3
+ const __langchain_core_messages = require_rolldown_runtime.__toESM(require("@langchain/core/messages"));
4
+
5
+ //#region src/chat_message_history.ts
6
+ var PostgresChatMessageHistory = class PostgresChatMessageHistory extends __langchain_core_chat_history.BaseChatMessageHistory {
7
+ lc_namespace = [
8
+ "langchain",
9
+ "stores",
10
+ "message",
11
+ "google-cloud-sql-pg"
12
+ ];
13
+ engine;
14
+ sessionId;
15
+ tableName;
16
+ schemaName;
17
+ constructor({ engine, sessionId, tableName, schemaName = "public" }) {
18
+ super();
19
+ this.engine = engine;
20
+ this.sessionId = sessionId;
21
+ this.tableName = tableName;
22
+ this.schemaName = schemaName;
23
+ }
24
+ /**
25
+ * Create a new PostgresChatMessageHistory instance.
26
+ *
27
+ * @param {PostgresEngine} engine Postgres engine instance to use.
28
+ * @param {string} sessionId Retrieve the table content with this session ID.
29
+ * @param {string} tableName Table name that stores that chat message history. Parameter is not escaped. Do not use with end user input.
30
+ * @param {string} schemaName Schema name for the chat message history table. Default: "public". Parameter is not escaped. Do not use with end user input.
31
+ * @returns PostgresChatMessageHistory instance.
32
+ */
33
+ static async initialize(engine, sessionId, tableName, schemaName = "public") {
34
+ const query = `SELECT column_name, data_type FROM information_schema.columns WHERE table_name = '${tableName}' AND table_schema = '${schemaName}'`;
35
+ const { rows } = await engine.pool.raw(query);
36
+ const columnNames = [];
37
+ for (const index in rows) if (Object.prototype.hasOwnProperty.call(rows, index)) columnNames.push(rows[index].column_name);
38
+ const requiredColumns = [
39
+ "id",
40
+ "session_id",
41
+ "data",
42
+ "type"
43
+ ];
44
+ if (!requiredColumns.every((x) => columnNames.includes(x))) throw new Error(`Table '${schemaName}'.'${tableName}' has incorrect schema.
70
45
  Got column names ${columnNames} but required column names ${requiredColumns}.
71
46
  Please create table with following schema: CREATE TABLE '${schemaName}'.'${tableName}' (
72
47
  id SERIAL AUTO_INCREMENT PRIMARY KEY,
@@ -75,72 +50,64 @@ class PostgresChatMessageHistory extends chat_history_1.BaseChatMessageHistory {
75
50
  type TEXT NOT NULL
76
51
  );
77
52
  `);
78
- }
79
- return new PostgresChatMessageHistory({
80
- engine,
81
- sessionId,
82
- tableName,
83
- schemaName,
84
- });
85
- }
86
- addUserMessage(message) {
87
- return this.addMessage(new messages_1.HumanMessage(message));
88
- }
89
- addAIChatMessage(message) {
90
- return this.addMessage(new messages_1.AIMessage(message));
91
- }
92
- /**
93
- * Returns a list of messages stored in the store.
94
- */
95
- async getMessages() {
96
- const query = `SELECT data, type FROM "${this.schemaName}"."${this.tableName}" WHERE session_id = :session_id ORDER BY id;`;
97
- const values = {
98
- session_id: this.sessionId,
99
- };
100
- const items = [];
101
- const { rows } = await this.engine.pool.raw(query, values);
102
- if (rows.length === 0) {
103
- return [];
104
- }
105
- for (const row of rows) {
106
- items.push({
107
- data: row.data.data,
108
- type: row.type,
109
- });
110
- }
111
- return (0, messages_1.mapStoredMessagesToChatMessages)(items);
112
- }
113
- /**
114
- * Add a message object to the store.
115
- * @param {BaseMessage} message Message to be added to the store
116
- */
117
- async addMessage(message) {
118
- const query = `INSERT INTO "${this.schemaName}"."${this.tableName}"("session_id", "data", "type") VALUES (:session_id, :data, :type)`;
119
- const values = {
120
- session_id: this.sessionId,
121
- data: JSON.stringify(message.toDict()),
122
- type: message.getType(),
123
- };
124
- await this.engine.pool.raw(query, values);
125
- }
126
- /**
127
- * Add a list of messages object to the store.
128
- * @param {Array<BaseMessage>} messages List of messages to be added to the store
129
- */
130
- async addMessages(messages) {
131
- for (const msg of messages) {
132
- await this.addMessage(msg);
133
- }
134
- }
135
- /**
136
- * Remove all messages from the store.
137
- */
138
- async clear() {
139
- const query = `DELETE FROM "${this.schemaName}"."${this.tableName}" WHERE session_id = :session_id;`;
140
- const values = {
141
- session_id: this.sessionId,
142
- };
143
- await this.engine.pool.raw(query, values);
144
- }
145
- }
53
+ return new PostgresChatMessageHistory({
54
+ engine,
55
+ sessionId,
56
+ tableName,
57
+ schemaName
58
+ });
59
+ }
60
+ addUserMessage(message) {
61
+ return this.addMessage(new __langchain_core_messages.HumanMessage(message));
62
+ }
63
+ addAIChatMessage(message) {
64
+ return this.addMessage(new __langchain_core_messages.AIMessage(message));
65
+ }
66
+ /**
67
+ * Returns a list of messages stored in the store.
68
+ */
69
+ async getMessages() {
70
+ const query = `SELECT data, type FROM "${this.schemaName}"."${this.tableName}" WHERE session_id = :session_id ORDER BY id;`;
71
+ const values = { session_id: this.sessionId };
72
+ const items = [];
73
+ const { rows } = await this.engine.pool.raw(query, values);
74
+ if (rows.length === 0) return [];
75
+ for (const row of rows) items.push({
76
+ data: row.data.data,
77
+ type: row.type
78
+ });
79
+ return (0, __langchain_core_messages.mapStoredMessagesToChatMessages)(items);
80
+ }
81
+ /**
82
+ * Add a message object to the store.
83
+ * @param {BaseMessage} message Message to be added to the store
84
+ */
85
+ async addMessage(message) {
86
+ const query = `INSERT INTO "${this.schemaName}"."${this.tableName}"("session_id", "data", "type") VALUES (:session_id, :data, :type)`;
87
+ const values = {
88
+ session_id: this.sessionId,
89
+ data: JSON.stringify(message.toDict()),
90
+ type: message.getType()
91
+ };
92
+ await this.engine.pool.raw(query, values);
93
+ }
94
+ /**
95
+ * Add a list of messages object to the store.
96
+ * @param {Array<BaseMessage>} messages List of messages to be added to the store
97
+ */
98
+ async addMessages(messages) {
99
+ for (const msg of messages) await this.addMessage(msg);
100
+ }
101
+ /**
102
+ * Remove all messages from the store.
103
+ */
104
+ async clear() {
105
+ const query = `DELETE FROM "${this.schemaName}"."${this.tableName}" WHERE session_id = :session_id;`;
106
+ const values = { session_id: this.sessionId };
107
+ await this.engine.pool.raw(query, values);
108
+ }
109
+ };
110
+
111
+ //#endregion
146
112
  exports.PostgresChatMessageHistory = PostgresChatMessageHistory;
113
+ //# sourceMappingURL=chat_message_history.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat_message_history.cjs","names":["BaseChatMessageHistory","engine: PostgresEngine","sessionId: string","tableName: string","schemaName: string","columnNames: string[]","message: string","HumanMessage","AIMessage","values: { [key: string]: string }","items: StoredMessage[]","message: BaseMessage","messages: BaseMessage[]"],"sources":["../src/chat_message_history.ts"],"sourcesContent":["import { BaseChatMessageHistory } from \"@langchain/core/chat_history\";\nimport {\n AIMessage,\n BaseMessage,\n HumanMessage,\n StoredMessage,\n mapStoredMessagesToChatMessages,\n} from \"@langchain/core/messages\";\nimport PostgresEngine from \"./engine.js\";\n\nexport interface PostgresChatMessageHistoryInput {\n engine: PostgresEngine;\n sessionId: string;\n tableName: string;\n schemaName: string;\n}\n\nexport class PostgresChatMessageHistory extends BaseChatMessageHistory {\n lc_namespace: string[] = [\n \"langchain\",\n \"stores\",\n \"message\",\n \"google-cloud-sql-pg\",\n ];\n\n engine: PostgresEngine;\n\n sessionId: string;\n\n tableName: string;\n\n schemaName: string;\n\n constructor({\n engine,\n sessionId,\n tableName,\n schemaName = \"public\",\n }: PostgresChatMessageHistoryInput) {\n super();\n this.engine = engine;\n this.sessionId = sessionId;\n this.tableName = tableName;\n this.schemaName = schemaName;\n }\n\n /**\n * Create a new PostgresChatMessageHistory instance.\n *\n * @param {PostgresEngine} engine Postgres engine instance to use.\n * @param {string} sessionId Retrieve the table content with this session ID.\n * @param {string} tableName Table name that stores that chat message history. Parameter is not escaped. Do not use with end user input.\n * @param {string} schemaName Schema name for the chat message history table. Default: \"public\". Parameter is not escaped. Do not use with end user input.\n * @returns PostgresChatMessageHistory instance.\n */\n static async initialize(\n engine: PostgresEngine,\n sessionId: string,\n tableName: string,\n schemaName: string = \"public\"\n ) {\n const query = `SELECT column_name, data_type FROM information_schema.columns WHERE table_name = '${tableName}' AND table_schema = '${schemaName}'`;\n const { rows } = await engine.pool.raw(query);\n const columnNames: string[] = [];\n\n for (const index in rows) {\n if (Object.prototype.hasOwnProperty.call(rows, index)) {\n columnNames.push(rows[index].column_name);\n }\n }\n\n const requiredColumns = [\"id\", \"session_id\", \"data\", \"type\"];\n\n if (!requiredColumns.every((x) => columnNames.includes(x))) {\n throw new Error(\n `Table '${schemaName}'.'${tableName}' has incorrect schema.\n Got column names ${columnNames} but required column names ${requiredColumns}.\n Please create table with following schema: CREATE TABLE '${schemaName}'.'${tableName}' (\n id SERIAL AUTO_INCREMENT PRIMARY KEY,\n session_id TEXT NOT NULL,\n data JSONB NOT NULL,\n type TEXT NOT NULL\n );\n `\n );\n }\n\n return new PostgresChatMessageHistory({\n engine,\n sessionId,\n tableName,\n schemaName,\n });\n }\n\n addUserMessage(message: string): Promise<void> {\n return this.addMessage(new HumanMessage(message));\n }\n\n addAIChatMessage(message: string): Promise<void> {\n return this.addMessage(new AIMessage(message));\n }\n\n /**\n * Returns a list of messages stored in the store.\n */\n async getMessages(): Promise<BaseMessage[]> {\n const query = `SELECT data, type FROM \"${this.schemaName}\".\"${this.tableName}\" WHERE session_id = :session_id ORDER BY id;`;\n const values: { [key: string]: string } = {\n session_id: this.sessionId,\n };\n const items: StoredMessage[] = [];\n const { rows } = await this.engine.pool.raw(query, values);\n\n if (rows.length === 0) {\n return [];\n }\n\n for (const row of rows) {\n items.push({\n data: row.data.data,\n type: row.type,\n });\n }\n\n return mapStoredMessagesToChatMessages(items);\n }\n\n /**\n * Add a message object to the store.\n * @param {BaseMessage} message Message to be added to the store\n */\n async addMessage(message: BaseMessage): Promise<void> {\n const query = `INSERT INTO \"${this.schemaName}\".\"${this.tableName}\"(\"session_id\", \"data\", \"type\") VALUES (:session_id, :data, :type)`;\n const values: { [key: string]: string } = {\n session_id: this.sessionId,\n data: JSON.stringify(message.toDict()),\n type: message.getType(),\n };\n\n await this.engine.pool.raw(query, values);\n }\n\n /**\n * Add a list of messages object to the store.\n * @param {Array<BaseMessage>} messages List of messages to be added to the store\n */\n async addMessages(messages: BaseMessage[]): Promise<void> {\n for (const msg of messages) {\n await this.addMessage(msg);\n }\n }\n\n /**\n * Remove all messages from the store.\n */\n async clear(): Promise<void> {\n const query = `DELETE FROM \"${this.schemaName}\".\"${this.tableName}\" WHERE session_id = :session_id;`;\n const values: { [key: string]: string } = {\n session_id: this.sessionId,\n };\n\n await this.engine.pool.raw(query, values);\n }\n}\n"],"mappings":";;;;;AAiBA,IAAa,6BAAb,MAAa,mCAAmCA,qDAAuB;CACrE,eAAyB;EACvB;EACA;EACA;EACA;CACD;CAED;CAEA;CAEA;CAEA;CAEA,YAAY,EACV,QACA,WACA,WACA,aAAa,UACmB,EAAE;EAClC,OAAO;EACP,KAAK,SAAS;EACd,KAAK,YAAY;EACjB,KAAK,YAAY;EACjB,KAAK,aAAa;CACnB;;;;;;;;;;CAWD,aAAa,WACXC,QACAC,WACAC,WACAC,aAAqB,UACrB;EACA,MAAM,QAAQ,CAAC,kFAAkF,EAAE,UAAU,sBAAsB,EAAE,WAAW,CAAC,CAAC;EAClJ,MAAM,EAAE,MAAM,GAAG,MAAM,OAAO,KAAK,IAAI,MAAM;EAC7C,MAAMC,cAAwB,CAAE;AAEhC,OAAK,MAAM,SAAS,KAClB,KAAI,OAAO,UAAU,eAAe,KAAK,MAAM,MAAM,EACnD,YAAY,KAAK,KAAK,OAAO,YAAY;EAI7C,MAAM,kBAAkB;GAAC;GAAM;GAAc;GAAQ;EAAO;AAE5D,MAAI,CAAC,gBAAgB,MAAM,CAAC,MAAM,YAAY,SAAS,EAAE,CAAC,CACxD,OAAM,IAAI,MACR,CAAC,OAAO,EAAE,WAAW,GAAG,EAAE,UAAU;yBACnB,EAAE,YAAY,2BAA2B,EAAE,gBAAgB;iEACnB,EAAE,WAAW,GAAG,EAAE,UAAU;;;;;;MAMvF,CAAC;AAIH,SAAO,IAAI,2BAA2B;GACpC;GACA;GACA;GACA;EACD;CACF;CAED,eAAeC,SAAgC;AAC7C,SAAO,KAAK,WAAW,IAAIC,uCAAa,SAAS;CAClD;CAED,iBAAiBD,SAAgC;AAC/C,SAAO,KAAK,WAAW,IAAIE,oCAAU,SAAS;CAC/C;;;;CAKD,MAAM,cAAsC;EAC1C,MAAM,QAAQ,CAAC,wBAAwB,EAAE,KAAK,WAAW,GAAG,EAAE,KAAK,UAAU,6CAA6C,CAAC;EAC3H,MAAMC,SAAoC,EACxC,YAAY,KAAK,UAClB;EACD,MAAMC,QAAyB,CAAE;EACjC,MAAM,EAAE,MAAM,GAAG,MAAM,KAAK,OAAO,KAAK,IAAI,OAAO,OAAO;AAE1D,MAAI,KAAK,WAAW,EAClB,QAAO,CAAE;AAGX,OAAK,MAAM,OAAO,MAChB,MAAM,KAAK;GACT,MAAM,IAAI,KAAK;GACf,MAAM,IAAI;EACX,EAAC;AAGJ,wEAAuC,MAAM;CAC9C;;;;;CAMD,MAAM,WAAWC,SAAqC;EACpD,MAAM,QAAQ,CAAC,aAAa,EAAE,KAAK,WAAW,GAAG,EAAE,KAAK,UAAU,kEAAkE,CAAC;EACrI,MAAMF,SAAoC;GACxC,YAAY,KAAK;GACjB,MAAM,KAAK,UAAU,QAAQ,QAAQ,CAAC;GACtC,MAAM,QAAQ,SAAS;EACxB;EAED,MAAM,KAAK,OAAO,KAAK,IAAI,OAAO,OAAO;CAC1C;;;;;CAMD,MAAM,YAAYG,UAAwC;AACxD,OAAK,MAAM,OAAO,UAChB,MAAM,KAAK,WAAW,IAAI;CAE7B;;;;CAKD,MAAM,QAAuB;EAC3B,MAAM,QAAQ,CAAC,aAAa,EAAE,KAAK,WAAW,GAAG,EAAE,KAAK,UAAU,iCAAiC,CAAC;EACpG,MAAMH,SAAoC,EACxC,YAAY,KAAK,UAClB;EAED,MAAM,KAAK,OAAO,KAAK,IAAI,OAAO,OAAO;CAC1C;AACF"}
@@ -0,0 +1,57 @@
1
+ import { PostgresEngine } from "./engine.cjs";
2
+ import { BaseChatMessageHistory } from "@langchain/core/chat_history";
3
+ import { BaseMessage } from "@langchain/core/messages";
4
+
5
+ //#region src/chat_message_history.d.ts
6
+ interface PostgresChatMessageHistoryInput {
7
+ engine: PostgresEngine;
8
+ sessionId: string;
9
+ tableName: string;
10
+ schemaName: string;
11
+ }
12
+ declare class PostgresChatMessageHistory extends BaseChatMessageHistory {
13
+ lc_namespace: string[];
14
+ engine: PostgresEngine;
15
+ sessionId: string;
16
+ tableName: string;
17
+ schemaName: string;
18
+ constructor({
19
+ engine,
20
+ sessionId,
21
+ tableName,
22
+ schemaName
23
+ }: PostgresChatMessageHistoryInput);
24
+ /**
25
+ * Create a new PostgresChatMessageHistory instance.
26
+ *
27
+ * @param {PostgresEngine} engine Postgres engine instance to use.
28
+ * @param {string} sessionId Retrieve the table content with this session ID.
29
+ * @param {string} tableName Table name that stores that chat message history. Parameter is not escaped. Do not use with end user input.
30
+ * @param {string} schemaName Schema name for the chat message history table. Default: "public". Parameter is not escaped. Do not use with end user input.
31
+ * @returns PostgresChatMessageHistory instance.
32
+ */
33
+ static initialize(engine: PostgresEngine, sessionId: string, tableName: string, schemaName?: string): Promise<PostgresChatMessageHistory>;
34
+ addUserMessage(message: string): Promise<void>;
35
+ addAIChatMessage(message: string): Promise<void>;
36
+ /**
37
+ * Returns a list of messages stored in the store.
38
+ */
39
+ getMessages(): Promise<BaseMessage[]>;
40
+ /**
41
+ * Add a message object to the store.
42
+ * @param {BaseMessage} message Message to be added to the store
43
+ */
44
+ addMessage(message: BaseMessage): Promise<void>;
45
+ /**
46
+ * Add a list of messages object to the store.
47
+ * @param {Array<BaseMessage>} messages List of messages to be added to the store
48
+ */
49
+ addMessages(messages: BaseMessage[]): Promise<void>;
50
+ /**
51
+ * Remove all messages from the store.
52
+ */
53
+ clear(): Promise<void>;
54
+ }
55
+ //#endregion
56
+ export { PostgresChatMessageHistory, PostgresChatMessageHistoryInput };
57
+ //# sourceMappingURL=chat_message_history.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat_message_history.d.cts","names":["BaseChatMessageHistory","BaseMessage","PostgresEngine","PostgresChatMessageHistoryInput","PostgresChatMessageHistory","engine","sessionId","tableName","schemaName","Promise"],"sources":["../src/chat_message_history.d.ts"],"sourcesContent":["import { BaseChatMessageHistory } from \"@langchain/core/chat_history\";\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport PostgresEngine from \"./engine.js\";\nexport interface PostgresChatMessageHistoryInput {\n engine: PostgresEngine;\n sessionId: string;\n tableName: string;\n schemaName: string;\n}\nexport declare class PostgresChatMessageHistory extends BaseChatMessageHistory {\n lc_namespace: string[];\n engine: PostgresEngine;\n sessionId: string;\n tableName: string;\n schemaName: string;\n constructor({ engine, sessionId, tableName, schemaName }: PostgresChatMessageHistoryInput);\n /**\n * Create a new PostgresChatMessageHistory instance.\n *\n * @param {PostgresEngine} engine Postgres engine instance to use.\n * @param {string} sessionId Retrieve the table content with this session ID.\n * @param {string} tableName Table name that stores that chat message history. Parameter is not escaped. Do not use with end user input.\n * @param {string} schemaName Schema name for the chat message history table. Default: \"public\". Parameter is not escaped. Do not use with end user input.\n * @returns PostgresChatMessageHistory instance.\n */\n static initialize(engine: PostgresEngine, sessionId: string, tableName: string, schemaName?: string): Promise<PostgresChatMessageHistory>;\n addUserMessage(message: string): Promise<void>;\n addAIChatMessage(message: string): Promise<void>;\n /**\n * Returns a list of messages stored in the store.\n */\n getMessages(): Promise<BaseMessage[]>;\n /**\n * Add a message object to the store.\n * @param {BaseMessage} message Message to be added to the store\n */\n addMessage(message: BaseMessage): Promise<void>;\n /**\n * Add a list of messages object to the store.\n * @param {Array<BaseMessage>} messages List of messages to be added to the store\n */\n addMessages(messages: BaseMessage[]): Promise<void>;\n /**\n * Remove all messages from the store.\n */\n clear(): Promise<void>;\n}\n"],"mappings":";;;;;UAGiBG,+BAAAA;UACLD;EADKC,SAAAA,EAAAA,MAAAA;EAMIC,SAAAA,EAAAA,MAAAA;EAA0B,UAAA,EAAA,MAAA;;AAM7BC,cANGD,0BAAAA,SAAmCJ,sBAAAA,CAMtCK;EAAM,YAAEC,EAAAA,MAAAA,EAAAA;EAAS,MAAEC,EAJzBL,cAIyBK;EAAS,SAAEC,EAAAA,MAAAA;EAAU,SAAIL,EAAAA,MAAAA;EAA+B,UAU/DD,EAAAA,MAAAA;EAAc,WAAsEE,CAAAA;IAAAA,MAAAA;IAAAA,SAAAA;IAAAA,SAAAA;IAAAA;EAAAA,CAAAA,EAVpDD,+BAUoDC;EAA0B;;;;;;;;;EAgB3F,OAIpCK,UAAAA,CAAAA,MAAAA,EApBiBP,cAoBjBO,EAAAA,SAAAA,EAAAA,MAAAA,EAAAA,SAAAA,EAAAA,MAAAA,EAAAA,UAAAA,CAAAA,EAAAA,MAAAA,CAAAA,EApB6FA,OAoB7FA,CApBqGL,0BAoBrGK,CAAAA;EAAO,cApCoCT,CAAAA,OAAAA,EAAAA,MAAAA,CAAAA,EAiBnBS,OAjBmBT,CAAAA,IAAAA,CAAAA;EAAsB,gBAAA,CAAA,OAAA,EAAA,MAAA,CAAA,EAkBvCS,OAlBuC,CAAA,IAAA,CAAA;;;;iBAsB3DA,QAAQR;;;;;sBAKHA,cAAcQ;;;;;wBAKZR,gBAAgBQ;;;;WAI7BA"}
@@ -1,47 +1,57 @@
1
+ import { PostgresEngine } from "./engine.js";
1
2
  import { BaseChatMessageHistory } from "@langchain/core/chat_history";
2
3
  import { BaseMessage } from "@langchain/core/messages";
3
- import PostgresEngine from "./engine.js";
4
- export interface PostgresChatMessageHistoryInput {
5
- engine: PostgresEngine;
6
- sessionId: string;
7
- tableName: string;
8
- schemaName: string;
4
+
5
+ //#region src/chat_message_history.d.ts
6
+ interface PostgresChatMessageHistoryInput {
7
+ engine: PostgresEngine;
8
+ sessionId: string;
9
+ tableName: string;
10
+ schemaName: string;
9
11
  }
10
- export declare class PostgresChatMessageHistory extends BaseChatMessageHistory {
11
- lc_namespace: string[];
12
- engine: PostgresEngine;
13
- sessionId: string;
14
- tableName: string;
15
- schemaName: string;
16
- constructor({ engine, sessionId, tableName, schemaName, }: PostgresChatMessageHistoryInput);
17
- /**
18
- * Create a new PostgresChatMessageHistory instance.
19
- *
20
- * @param {PostgresEngine} engine Postgres engine instance to use.
21
- * @param {string} sessionId Retrieve the table content with this session ID.
22
- * @param {string} tableName Table name that stores that chat message history. Parameter is not escaped. Do not use with end user input.
23
- * @param {string} schemaName Schema name for the chat message history table. Default: "public". Parameter is not escaped. Do not use with end user input.
24
- * @returns PostgresChatMessageHistory instance.
25
- */
26
- static initialize(engine: PostgresEngine, sessionId: string, tableName: string, schemaName?: string): Promise<PostgresChatMessageHistory>;
27
- addUserMessage(message: string): Promise<void>;
28
- addAIChatMessage(message: string): Promise<void>;
29
- /**
30
- * Returns a list of messages stored in the store.
31
- */
32
- getMessages(): Promise<BaseMessage[]>;
33
- /**
34
- * Add a message object to the store.
35
- * @param {BaseMessage} message Message to be added to the store
36
- */
37
- addMessage(message: BaseMessage): Promise<void>;
38
- /**
39
- * Add a list of messages object to the store.
40
- * @param {Array<BaseMessage>} messages List of messages to be added to the store
41
- */
42
- addMessages(messages: BaseMessage[]): Promise<void>;
43
- /**
44
- * Remove all messages from the store.
45
- */
46
- clear(): Promise<void>;
12
+ declare class PostgresChatMessageHistory extends BaseChatMessageHistory {
13
+ lc_namespace: string[];
14
+ engine: PostgresEngine;
15
+ sessionId: string;
16
+ tableName: string;
17
+ schemaName: string;
18
+ constructor({
19
+ engine,
20
+ sessionId,
21
+ tableName,
22
+ schemaName
23
+ }: PostgresChatMessageHistoryInput);
24
+ /**
25
+ * Create a new PostgresChatMessageHistory instance.
26
+ *
27
+ * @param {PostgresEngine} engine Postgres engine instance to use.
28
+ * @param {string} sessionId Retrieve the table content with this session ID.
29
+ * @param {string} tableName Table name that stores that chat message history. Parameter is not escaped. Do not use with end user input.
30
+ * @param {string} schemaName Schema name for the chat message history table. Default: "public". Parameter is not escaped. Do not use with end user input.
31
+ * @returns PostgresChatMessageHistory instance.
32
+ */
33
+ static initialize(engine: PostgresEngine, sessionId: string, tableName: string, schemaName?: string): Promise<PostgresChatMessageHistory>;
34
+ addUserMessage(message: string): Promise<void>;
35
+ addAIChatMessage(message: string): Promise<void>;
36
+ /**
37
+ * Returns a list of messages stored in the store.
38
+ */
39
+ getMessages(): Promise<BaseMessage[]>;
40
+ /**
41
+ * Add a message object to the store.
42
+ * @param {BaseMessage} message Message to be added to the store
43
+ */
44
+ addMessage(message: BaseMessage): Promise<void>;
45
+ /**
46
+ * Add a list of messages object to the store.
47
+ * @param {Array<BaseMessage>} messages List of messages to be added to the store
48
+ */
49
+ addMessages(messages: BaseMessage[]): Promise<void>;
50
+ /**
51
+ * Remove all messages from the store.
52
+ */
53
+ clear(): Promise<void>;
47
54
  }
55
+ //#endregion
56
+ export { PostgresChatMessageHistory, PostgresChatMessageHistoryInput };
57
+ //# sourceMappingURL=chat_message_history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat_message_history.d.ts","names":["BaseChatMessageHistory","BaseMessage","PostgresEngine","PostgresChatMessageHistoryInput","PostgresChatMessageHistory","engine","sessionId","tableName","schemaName","Promise"],"sources":["../src/chat_message_history.d.ts"],"sourcesContent":["import { BaseChatMessageHistory } from \"@langchain/core/chat_history\";\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport PostgresEngine from \"./engine.js\";\nexport interface PostgresChatMessageHistoryInput {\n engine: PostgresEngine;\n sessionId: string;\n tableName: string;\n schemaName: string;\n}\nexport declare class PostgresChatMessageHistory extends BaseChatMessageHistory {\n lc_namespace: string[];\n engine: PostgresEngine;\n sessionId: string;\n tableName: string;\n schemaName: string;\n constructor({ engine, sessionId, tableName, schemaName }: PostgresChatMessageHistoryInput);\n /**\n * Create a new PostgresChatMessageHistory instance.\n *\n * @param {PostgresEngine} engine Postgres engine instance to use.\n * @param {string} sessionId Retrieve the table content with this session ID.\n * @param {string} tableName Table name that stores that chat message history. Parameter is not escaped. Do not use with end user input.\n * @param {string} schemaName Schema name for the chat message history table. Default: \"public\". Parameter is not escaped. Do not use with end user input.\n * @returns PostgresChatMessageHistory instance.\n */\n static initialize(engine: PostgresEngine, sessionId: string, tableName: string, schemaName?: string): Promise<PostgresChatMessageHistory>;\n addUserMessage(message: string): Promise<void>;\n addAIChatMessage(message: string): Promise<void>;\n /**\n * Returns a list of messages stored in the store.\n */\n getMessages(): Promise<BaseMessage[]>;\n /**\n * Add a message object to the store.\n * @param {BaseMessage} message Message to be added to the store\n */\n addMessage(message: BaseMessage): Promise<void>;\n /**\n * Add a list of messages object to the store.\n * @param {Array<BaseMessage>} messages List of messages to be added to the store\n */\n addMessages(messages: BaseMessage[]): Promise<void>;\n /**\n * Remove all messages from the store.\n */\n clear(): Promise<void>;\n}\n"],"mappings":";;;;;UAGiBG,+BAAAA;UACLD;EADKC,SAAAA,EAAAA,MAAAA;EAMIC,SAAAA,EAAAA,MAAAA;EAA0B,UAAA,EAAA,MAAA;;AAM7BC,cANGD,0BAAAA,SAAmCJ,sBAAAA,CAMtCK;EAAM,YAAEC,EAAAA,MAAAA,EAAAA;EAAS,MAAEC,EAJzBL,cAIyBK;EAAS,SAAEC,EAAAA,MAAAA;EAAU,SAAIL,EAAAA,MAAAA;EAA+B,UAU/DD,EAAAA,MAAAA;EAAc,WAAsEE,CAAAA;IAAAA,MAAAA;IAAAA,SAAAA;IAAAA,SAAAA;IAAAA;EAAAA,CAAAA,EAVpDD,+BAUoDC;EAA0B;;;;;;;;;EAgB3F,OAIpCK,UAAAA,CAAAA,MAAAA,EApBiBP,cAoBjBO,EAAAA,SAAAA,EAAAA,MAAAA,EAAAA,SAAAA,EAAAA,MAAAA,EAAAA,UAAAA,CAAAA,EAAAA,MAAAA,CAAAA,EApB6FA,OAoB7FA,CApBqGL,0BAoBrGK,CAAAA;EAAO,cApCoCT,CAAAA,OAAAA,EAAAA,MAAAA,CAAAA,EAiBnBS,OAjBmBT,CAAAA,IAAAA,CAAAA;EAAsB,gBAAA,CAAA,OAAA,EAAA,MAAA,CAAA,EAkBvCS,OAlBuC,CAAA,IAAA,CAAA;;;;iBAsB3DA,QAAQR;;;;;sBAKHA,cAAcQ;;;;;wBAKZR,gBAAgBQ;;;;WAI7BA"}