@langchain/community
Version:
Third-party integrations for LangChain.js
1 lines • 4.06 kB
Source Map (JSON)
{"version":3,"file":"postgres.d.ts","names":["BaseListChatMessageHistory","BaseMessage","pg","PostgresChatMessageHistoryInput","PoolConfig","Pool","StoredPostgresMessageData","Record","PostgresChatMessageHistory","Promise"],"sources":["../../../src/stores/message/postgres.d.ts"],"sourcesContent":["import { BaseListChatMessageHistory } from \"@langchain/core/chat_history\";\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport pg from \"pg\";\n/**\n * Type definition for the input parameters required when instantiating a\n * PostgresChatMessageHistory object.\n */\nexport type PostgresChatMessageHistoryInput = {\n /**\n * Name of the table to use when storing and retrieving chat message\n */\n tableName?: string;\n /**\n * Session ID to use when storing and retrieving chat message history.\n */\n sessionId: string;\n /**\n * Configuration object for the Postgres pool. If provided the\n * PostgresChatMessageHistory object will create a new pool using\n * the provided configuration. Otherwise it will use the provided\n * pool.\n */\n poolConfig?: pg.PoolConfig;\n /**\n * Postgres pool to use. If provided the PostgresChatMessageHistory\n * object will use the provided pool. Otherwise it will create a\n * new pool using the provided configuration.\n */\n pool?: pg.Pool;\n /**\n * If true, the table name will be escaped. ('lAnGcHaIn' will be escaped to '\"lAnGcHaIn\"')\n */\n escapeTableName?: boolean;\n};\nexport interface StoredPostgresMessageData {\n name: string | undefined;\n role: string | undefined;\n content: string;\n additional_kwargs?: Record<string, unknown>;\n type: string;\n tool_call_id: string | undefined;\n}\n/**\n * Class for managing chat message history using a Postgres Database as a\n * storage backend. Extends the BaseListChatMessageHistory class.\n * @example\n * ```typescript\n * const chatHistory = new PostgresChatMessageHistory({\n * tableName: \"langchain_chat_histories\",\n * sessionId: \"lc-example\",\n * pool: new pg.Pool({\n * host: \"127.0.0.1\",\n * port: 5432,\n * user: \"myuser\",\n * password: \"ChangeMe\",\n * database: \"api\",\n * }),\n * });\n * ```\n */\nexport declare class PostgresChatMessageHistory extends BaseListChatMessageHistory {\n lc_namespace: string[];\n pool: pg.Pool;\n tableName: string;\n sessionId: string;\n private initialized;\n /**\n * Creates a new PostgresChatMessageHistory.\n * @param {PostgresChatMessageHistoryInput} fields The input fields for the PostgresChatMessageHistory.\n * @param {string} fields.tableName The name of the table name to use. Defaults to `langchain_chat_histories`.\n * @param {string} fields.sessionId The session ID to use when storing and retrieving chat message history.\n * @param {pg.Pool} fields.pool The Postgres pool to use. If provided, the PostgresChatMessageHistory will use the provided pool.\n * @param {pg.PoolConfig} fields.poolConfig The configuration object for the Postgres pool. If no pool is provided, the conig will be used to create a new pool.\n * If `pool` is provided, it will be used as the Postgres pool even if `poolConfig` is also provided.\n * @throws If neither `pool` nor `poolConfig` is provided.\n */\n constructor(fields: PostgresChatMessageHistoryInput);\n private ensureTable;\n addMessage(message: BaseMessage): Promise<void>;\n getMessages(): Promise<BaseMessage[]>;\n clear(): Promise<void>;\n /**\n * End the Postgres pool.\n */\n end(): Promise<void>;\n}\n//# sourceMappingURL=postgres.d.ts.map"],"mappings":";;;;;;;;AAOA;AA2BA;AA0BqBQ,KArDTL,+BAAAA,GAqDmC;EAElCE;;;EAgByBI,SAAAA,CAAAA,EAAAA,MAAAA;EACXR;;;EAKhBQ,SAAAA,EAAAA,MAAAA;EAxB6CT;AAA0B;;;;;eAtCjEE,EAAAA,CAAGE;;;;;;SAMTF,EAAAA,CAAGG;;;;;;UAMGC,yBAAAA;;;;sBAIOC;;;;;;;;;;;;;;;;;;;;;;cAsBHC,0BAAAA,SAAmCR,0BAAAA;;QAE9CE,EAAAA,CAAGG;;;;;;;;;;;;;;sBAcWF;;sBAEAF,cAAcQ;iBACnBA,QAAQR;WACdQ;;;;SAIFA"}