{"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 = (\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\n...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(\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    inputValue: string | BaseMessage | Array<BaseMessage> | Record<string, any>): Array<BaseMessage>;\n    _getOutputMessages(\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    outputValue: string | BaseMessage | Array<BaseMessage> | Record<string, any>): Array<BaseMessage>;\n    _enterHistory(\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    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"],"mappings":";;;;;;;KAKKQ,yBAAAA;;AADwC,GAAA,IACxCA,EAEIC,KAFJD,CAAAA,GAAAA,CAAAA,EAAAA,GAEmBE,OAFnBF,CAE2BR,sBAFF,GAE2BC,0BAF3B,CAAA,GAEyDD,sBAFzD,GAEkFC,0BAFlF;AAAA,UAGbU,gCAHa,CAAA,QAAA,EAAA,SAAA,CAAA,SAGiDG,IAHjD,CAGsDR,mBAHtD,CAG0EM,QAH1E,EAGoFC,SAHpF,CAAA,EAAA,OAAA,GAAA,QAAA,CAAA,CAAA;EAAA,QAErBJ,EAEKL,QAFLK,CAEcG,QAFdH,EAEwBI,SAFxBJ,CAAAA;EAAK,iBAAkBT,EAGTQ,yBAHSR;EAAsB,gBAAGC,CAAAA,EAAAA,MAAAA;EAA0B,iBAA3DS,CAAAA,EAAAA,MAAAA;EAAO,kBAAwDV,CAAAA,EAAAA,MAAAA;EAAsB,MAAGC,CAAAA,EAOnGM,cAPmGN;AAA0B;AAC1I;;;;;;;;;;;AAAmF;AAwEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA4F;;;;;;;;;;;;;;;;cAAvEc,wDAAwDV,gBAAgBO,UAAUC;YACzFT,SAASQ,UAAUC;;;;qBAIVL;sBACCG,iCAAiCC,UAAUC;;;uBAG1CX,cAAcO,MAAMP,eAAec,sBAAsBP,MAAMP;;;wBAG9DA,cAAcO,MAAMP,eAAec,sBAAsBP,MAAMP;;;uBAGhEK,iBAAiBG,QAAQR;oBAC5BC,aAAaI,iBAAiBG;2BACvBD,MAAMF,8BAA8BG,QAAQO,QAAQV,eAAeS"}