{"version":3,"file":"history.d.cts","names":["BaseChatMessageHistory","BaseListChatMessageHistory","BaseMessage","Run","Runnable","RunnableBinding","RunnableBindingArgs","RunnableConfig","GetSessionHistoryCallable","Array","Promise","RunnableWithMessageHistoryInputs","RunInput","RunOutput","Omit","RunnableWithMessageHistory","Record","Partial"],"sources":["../../src/runnables/history.d.ts"],"sourcesContent":["import { BaseChatMessageHistory, BaseListChatMessageHistory } from \"../chat_history.js\";\nimport { BaseMessage } from \"../messages/index.js\";\nimport { Run } from \"../tracers/base.js\";\nimport { Runnable, RunnableBinding, type RunnableBindingArgs } from \"./base.js\";\nimport { RunnableConfig } from \"./config.js\";\ntype GetSessionHistoryCallable = (...args: Array<any>) => Promise<BaseChatMessageHistory | BaseListChatMessageHistory> | BaseChatMessageHistory | BaseListChatMessageHistory;\nexport interface RunnableWithMessageHistoryInputs<RunInput, RunOutput> extends Omit<RunnableBindingArgs<RunInput, RunOutput>, \"bound\" | \"config\"> {\n    runnable: Runnable<RunInput, RunOutput>;\n    getMessageHistory: GetSessionHistoryCallable;\n    inputMessagesKey?: string;\n    outputMessagesKey?: string;\n    historyMessagesKey?: string;\n    config?: RunnableConfig;\n}\n/**\n * Wraps a LCEL chain and manages history. It appends input messages\n * and chain outputs as history, and adds the current history messages to\n * the chain input.\n * @example\n * ```typescript\n * // pnpm install @langchain/anthropic @langchain/community @upstash/redis\n *\n * import {\n *   ChatPromptTemplate,\n *   MessagesPlaceholder,\n * } from \"@langchain/core/prompts\";\n * import { ChatAnthropic } from \"@langchain/anthropic\";\n * import { UpstashRedisChatMessageHistory } from \"@langchain/community/stores/message/upstash_redis\";\n * // For demos, you can also use an in-memory store:\n * // import { ChatMessageHistory } from \"@langchain/classic/stores/message/in_memory\";\n *\n * const prompt = ChatPromptTemplate.fromMessages([\n *   [\"system\", \"You're an assistant who's good at {ability}\"],\n *   new MessagesPlaceholder(\"history\"),\n *   [\"human\", \"{question}\"],\n * ]);\n *\n * const chain = prompt.pipe(new ChatAnthropic({}));\n *\n * const chainWithHistory = new RunnableWithMessageHistory({\n *   runnable: chain,\n *   getMessageHistory: (sessionId) =>\n *     new UpstashRedisChatMessageHistory({\n *       sessionId,\n *       config: {\n *         url: process.env.UPSTASH_REDIS_REST_URL!,\n *         token: process.env.UPSTASH_REDIS_REST_TOKEN!,\n *       },\n *     }),\n *   inputMessagesKey: \"question\",\n *   historyMessagesKey: \"history\",\n * });\n *\n * const result = await chainWithHistory.invoke(\n *   {\n *     ability: \"math\",\n *     question: \"What does cosine mean?\",\n *   },\n *   {\n *     configurable: {\n *       sessionId: \"some_string_identifying_a_user\",\n *     },\n *   }\n * );\n *\n * const result2 = await chainWithHistory.invoke(\n *   {\n *     ability: \"math\",\n *     question: \"What's its inverse?\",\n *   },\n *   {\n *     configurable: {\n *       sessionId: \"some_string_identifying_a_user\",\n *     },\n *   }\n * );\n * ```\n */\nexport declare class RunnableWithMessageHistory<RunInput, RunOutput> extends RunnableBinding<RunInput, RunOutput> {\n    runnable: Runnable<RunInput, RunOutput>;\n    inputMessagesKey?: string;\n    outputMessagesKey?: string;\n    historyMessagesKey?: string;\n    getMessageHistory: GetSessionHistoryCallable;\n    constructor(fields: RunnableWithMessageHistoryInputs<RunInput, RunOutput>);\n    _getInputMessages(inputValue: string | BaseMessage | Array<BaseMessage> | Record<string, any>): Array<BaseMessage>;\n    _getOutputMessages(outputValue: string | BaseMessage | Array<BaseMessage> | Record<string, any>): Array<BaseMessage>;\n    _enterHistory(input: any, kwargs?: RunnableConfig): Promise<BaseMessage[]>;\n    _exitHistory(run: Run, config: RunnableConfig): Promise<void>;\n    _mergeConfig(...configs: Array<RunnableConfig | undefined>): Promise<Partial<RunnableConfig<Record<string, any>>>>;\n}\nexport {};\n//# sourceMappingURL=history.d.ts.map"],"mappings":";;;;;;;KAKKQ,yBAAAA,aAAsCC,eAAeC,QAAQV,yBAAyBC,8BAA8BD,yBAAyBC;UACjIU,8DAA8DG,KAAKR,oBAAoBM,UAAUC;EAD7GL,QAAAA,EAESJ,QAFTI,CAEkBI,QAFlBJ,EAE4BK,SAFH,CAAA;EAAaJ,iBAAAA,EAGpBD,yBAHoBC;EAAuBT,gBAAAA,CAAAA,EAAAA,MAAAA;EAAyBC,iBAAAA,CAAAA,EAAAA,MAAAA;EAAjCS,kBAAAA,CAAAA,EAAAA,MAAAA;EAA+DV,MAAAA,CAAAA,EAO5GO,cAP4GP;;AAAmD;AAC5K;;;;;;;;;;AAAmF;AAwEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA4F;;;;;;;;;;;;;;;;;cAAvEe,wDAAwDV,gBAAgBO,UAAUC;YACzFT,SAASQ,UAAUC;;;;qBAIVL;sBACCG,iCAAiCC,UAAUC;yCACxBX,cAAcO,MAAMP,eAAec,sBAAsBP,MAAMP;2CAC7DA,cAAcO,MAAMP,eAAec,sBAAsBP,MAAMP;qCACrEK,iBAAiBG,QAAQR;oBAC1CC,aAAaI,iBAAiBG;2BACvBD,MAAMF,8BAA8BG,QAAQO,QAAQV,eAAeS"}