{"version":3,"file":"conversation.cjs","names":["LLMChain","PromptTemplate","BufferMemory"],"sources":["../../src/chains/conversation.ts"],"sourcesContent":["import { PromptTemplate } from \"@langchain/core/prompts\";\nimport { LLMChain, LLMChainInput } from \"./llm_chain.js\";\nimport { BufferMemory } from \"../memory/buffer_memory.js\";\nimport { Optional } from \"../types/type-utils.js\";\n\nexport const DEFAULT_TEMPLATE = `The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.\n\nCurrent conversation:\n{history}\nHuman: {input}\nAI:`;\n\n/**\n * A class for conducting conversations between a human and an AI. It\n * extends the {@link LLMChain} class.\n * @example\n * ```typescript\n * const model = new ChatOpenAI({ model: \"gpt-4o-mini\" });\n * const chain = new ConversationChain({ llm: model });\n *\n * // Sending a greeting to the conversation chain\n * const res1 = await chain.call({ input: \"Hi! I'm Jim.\" });\n * console.log({ res1 });\n *\n * // Following up with a question in the conversation\n * const res2 = await chain.call({ input: \"What's my name?\" });\n * console.log({ res2 });\n * ```\n */\nexport class ConversationChain extends LLMChain {\n  static lc_name() {\n    return \"ConversationChain\";\n  }\n\n  constructor({\n    prompt,\n    outputKey,\n    memory,\n    ...rest\n  }: Optional<LLMChainInput, \"prompt\">) {\n    super({\n      prompt:\n        prompt ??\n        new PromptTemplate({\n          template: DEFAULT_TEMPLATE,\n          inputVariables: [\"history\", \"input\"],\n        }),\n      outputKey: outputKey ?? \"response\",\n      memory: memory ?? new BufferMemory(),\n      ...rest,\n    });\n  }\n}\n"],"mappings":";;;;;AAKA,MAAa,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;AAwBhC,IAAa,oBAAb,cAAuCA,kBAAAA,SAAS;CAC9C,OAAO,UAAU;AACf,SAAO;;CAGT,YAAY,EACV,QACA,WACA,QACA,GAAG,QACiC;AACpC,QAAM;GACJ,QACE,UACA,IAAIC,wBAAAA,eAAe;IACjB,UAAU;IACV,gBAAgB,CAAC,WAAW,QAAQ;IACrC,CAAC;GACJ,WAAW,aAAa;GACxB,QAAQ,UAAU,IAAIC,sBAAAA,cAAc;GACpC,GAAG;GACJ,CAAC"}