@langchain/community
Version:
Third-party integrations for LangChain.js
1 lines • 4.35 kB
Source Map (JSON)
{"version":3,"file":"momento.d.ts","names":["ICacheClient","BaseListChatMessageHistory","BaseMessage","MomentoChatMessageHistoryProps","MomentoChatMessageHistory","Promise"],"sources":["../../../src/stores/message/momento.d.ts"],"sourcesContent":["import { ICacheClient } from \"@gomomento/sdk-core\";\nimport { BaseListChatMessageHistory } from \"@langchain/core/chat_history\";\nimport { BaseMessage } from \"@langchain/core/messages\";\n/**\n * The settings to instantiate the Momento chat message history.\n */\nexport interface MomentoChatMessageHistoryProps {\n /**\n * The session ID to use to store the data.\n */\n sessionId: string;\n /**\n * The Momento cache client.\n */\n client: ICacheClient;\n /**\n * The name of the cache to use to store the data.\n */\n cacheName: string;\n /**\n * The time to live for the cache items in seconds.\n * If not specified, the cache client default is used.\n */\n sessionTtl?: number;\n /**\n * If true, ensure that the cache exists before returning.\n * If false, the cache is not checked for existence.\n * Defaults to true.\n */\n ensureCacheExists?: true;\n}\n/**\n * A class that stores chat message history using Momento Cache. It\n * interacts with a Momento cache client to perform operations like\n * fetching, adding, and deleting messages.\n * @example\n * ```typescript\n * const chatHistory = await MomentoChatMessageHistory.fromProps({\n * client: new CacheClient({\n * configuration: Configurations.Laptop.v1(),\n * credentialProvider: CredentialProvider.fromEnvironmentVariable({\n * environmentVariableName: \"MOMENTO_API_KEY\",\n * }),\n * defaultTtlSeconds: 60 * 60 * 24,\n * }),\n * cacheName: \"langchain\",\n * sessionId: new Date().toISOString(),\n * sessionTtl: 300,\n * });\n *\n * const messages = await chatHistory.getMessages();\n * console.log({ messages });\n * ```\n */\nexport declare class MomentoChatMessageHistory extends BaseListChatMessageHistory {\n lc_namespace: string[];\n private readonly sessionId;\n private readonly client;\n private readonly cacheName;\n private readonly sessionTtl;\n private constructor();\n /**\n * Create a new chat message history backed by Momento.\n *\n * @param {MomentoCacheProps} props The settings to instantiate the Momento chat message history.\n * @param {string} props.sessionId The session ID to use to store the data.\n * @param {ICacheClient} props.client The Momento cache client.\n * @param {string} props.cacheName The name of the cache to use to store the data.\n * @param {number} props.sessionTtl The time to live for the cache items in seconds.\n * If not specified, the cache client default is used.\n * @param {boolean} props.ensureCacheExists If true, ensure that the cache exists before returning.\n * If false, the cache is not checked for existence.\n * @throws {InvalidArgumentError} If {@link props.sessionTtl} is not strictly positive.\n * @returns A new chat message history backed by Momento.\n */\n static fromProps(props: MomentoChatMessageHistoryProps): Promise<MomentoChatMessageHistory>;\n /**\n * Validate the user-specified TTL, if provided, is strictly positive.\n * @param ttlSeconds The TTL to validate.\n */\n private validateTtlSeconds;\n /**\n * Fetches messages from the cache.\n * @returns A Promise that resolves to an array of BaseMessage instances.\n */\n getMessages(): Promise<BaseMessage[]>;\n /**\n * Adds a message to the cache.\n * @param message The BaseMessage instance to add to the cache.\n * @returns A Promise that resolves when the message has been added.\n */\n addMessage(message: BaseMessage): Promise<void>;\n /**\n * Deletes all messages from the cache.\n * @returns A Promise that resolves when all messages have been deleted.\n */\n clear(): Promise<void>;\n}\n//# sourceMappingURL=momento.d.ts.map"],"mappings":";;;;;;;;AAMA;AAgDqBI,UAhDJD,8BAAAA,CAgD6B;EAqBlBA;;;EAUDD,SAAAA,EAAAA,MAAAA;EAARG;;;EAWNA,MAAAA,EAlFDL,YAkFCK;EA1C0CJ;AAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAA5DG,yBAAAA,SAAkCH,0BAAAA;;;;;;;;;;;;;;;;;;;;;0BAqB3BE,iCAAiCE,QAAQD;;;;;;;;;;iBAUlDC,QAAQH;;;;;;sBAMHA,cAAcG;;;;;WAKzBA"}