{"version":3,"file":"task_creation.cjs","names":["LLMChain","PromptTemplate"],"sources":["../../../src/experimental/babyagi/task_creation.ts"],"sourcesContent":["import { PromptTemplate } from \"@langchain/core/prompts\";\nimport { LLMChain, LLMChainInput } from \"../../chains/llm_chain.js\";\n\n/** Chain to generate tasks. */\nexport class TaskCreationChain extends LLMChain {\n  static lc_name() {\n    return \"TaskCreationChain\";\n  }\n\n  /**\n   * Creates a new TaskCreationChain instance. It takes an object of type\n   * LLMChainInput as input, omitting the 'prompt' field. It uses the\n   * PromptTemplate class to create a new prompt based on the task creation\n   * template and the input variables. The new TaskCreationChain instance is\n   * then created with this prompt and the remaining fields from the input\n   * object.\n   * @param fields An object of type LLMChainInput, omitting the 'prompt' field.\n   * @returns A new instance of TaskCreationChain.\n   */\n  static fromLLM(fields: Omit<LLMChainInput, \"prompt\">): LLMChain {\n    const taskCreationTemplate =\n      `You are an task creation AI that uses the result of an execution agent` +\n      ` to create new tasks with the following objective: {objective},` +\n      ` The last completed task has the result: {result}.` +\n      ` This result was based on this task description: {task_description}.` +\n      ` These are incomplete tasks: {incomplete_tasks}.` +\n      ` Based on the result, create new tasks to be completed` +\n      ` by the AI system that do not overlap with incomplete tasks.` +\n      ` Return the tasks as an array.`;\n    const prompt = new PromptTemplate({\n      template: taskCreationTemplate,\n      inputVariables: [\n        \"result\",\n        \"task_description\",\n        \"incomplete_tasks\",\n        \"objective\",\n      ],\n    });\n    return new TaskCreationChain({ prompt, ...fields });\n  }\n}\n"],"mappings":";;;;;AAIA,IAAa,oBAAb,MAAa,0BAA0BA,kBAAAA,SAAS;CAC9C,OAAO,UAAU;AACf,SAAO;;;;;;;;;;;;CAaT,OAAO,QAAQ,QAAiD;AAmB9D,SAAO,IAAI,kBAAkB;GAAE,QAThB,IAAIC,wBAAAA,eAAe;IAChC,UATA;IAUA,gBAAgB;KACd;KACA;KACA;KACA;KACD;IACF,CAAC;GACqC,GAAG;GAAQ,CAAC"}