{"version":3,"sources":["../../../src/agents/bee/prompts.ts"],"names":["BeeSystemPrompt","PromptTemplate","schema","z","object","instructions","string","default","tools","array","name","min","description","passthrough","createdAt","datetime","nullish","template","BeeAssistantPrompt","thought","toolName","toolInput","toolOutput","finalAnswer","partial","BeeUserPrompt","input","meta","optional","functions","formatMeta","parts","filter","Boolean","join","BeeUserEmptyPrompt","BeeToolErrorPrompt","reason","BeeToolInputErrorPrompt","BeeToolNoResultsPrompt","record","any","BeeToolNotFoundPrompt","BeeSchemaErrorPrompt"],"mappings":";;;;;;;AAoBaA,MAAAA,eAAAA,GAAkB,IAAIC,2BAAe,CAAA;AAChDC,EAAAA,MAAAA,EAAQC,MAAEC,MAAO,CAAA;AACfC,IAAAA,YAAAA,EAAcF,KAAEG,CAAAA,MAAAA,EAASC,CAAAA,OAAAA,CAAQ,8BAAA,CAAA;IACjCC,KAAOL,EAAAA,KAAAA,CAAEM,KACPN,CAAAA,KAAAA,CACGC,MAAO,CAAA;AACNM,MAAAA,IAAAA,EAAMP,KAAEG,CAAAA,MAAAA,EAASK,CAAAA,GAAAA,CAAI,CAAA,CAAA;AACrBC,MAAAA,WAAAA,EAAaT,KAAEG,CAAAA,MAAAA,EAASK,CAAAA,GAAAA,CAAI,CAAA,CAAA;AAC5BT,MAAAA,MAAAA,EAAQC,KAAEG,CAAAA,MAAAA,EAASK,CAAAA,GAAAA,CAAI,CAAA;KACzB,CAAA,CACCE,aAAW,CAAA;AAEhBC,IAAAA,SAAAA,EAAWX,KAAEG,CAAAA,MAAAA,EAASS,CAAAA,QAAAA,GAAWC,OAAO;GAC1C,CAAA;EACAC,QAAU,EAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEZ,CAAA;AAEaC,MAAAA,kBAAAA,GAAqB,IAAIjB,2BAAe,CAAA;AACnDC,EAAAA,MAAAA,EAAQC,MACLC,MAAO,CAAA;AACNe,IAAAA,OA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,QAAU,EAAA,CAAA;;;;AAIZ,CAAA;AAEa0B,MAAAA,oBAAAA,GAAuB,IAAI1C,2BAAe,CAAA;AACrDC,EAAAA,MAAAA,EAAQC,KAAEC,CAAAA,MAAAA,CAAO,EAAC,EAAGS,WAAW,EAAA;EAChCI,QAAU,EAAA,CAAA;;AAEZ,CAAA","file":"prompts.cjs","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PromptTemplate } from \"@/template.js\";\nimport { BaseMessageMeta } from \"@/llms/primitives/message.js\";\nimport { z } from \"zod\";\n\nexport const BeeSystemPrompt = new PromptTemplate({\n  schema: z.object({\n    instructions: z.string().default(\"You are a helpful assistant.\"),\n    tools: z.array(\n      z\n        .object({\n          name: z.string().min(1),\n          description: z.string().min(1),\n          schema: z.string().min(1),\n        })\n        .passthrough(),\n    ),\n    createdAt: z.string().datetime().nullish(),\n  }),\n  template: `# Available functions\n{{#tools.length}}\nYou can only use the following functions. Always use all required parameters.\n\n{{#tools}}\nFunction Name: {{name}}\nDescription: {{description}}\nParameters: {{schema}}\n\n{{/tools}}\n{{/tools.length}}\n{{^tools.length}}\nNo functions are available.\n\n{{/tools.length}}\n# Communication structure\nYou communicate only in instruction lines. The format is: \"Instruction: expected output\\n\". You must only use these instruction lines and must not enter empty lines between them. Each instruction must start on a new line.\n{{#tools.length}}\nYou must skip the instruction lines Function Name, Function Input and Function Output if no function calling is required.\n{{/tools.length}}\n\nMessage: User's message. You never use this instruction line.\n{{^tools.length}}\nThought: A single-line plan of how to answer the user's message, including an explanation of the reasoning behind it. It must be immediately followed by Final Answer.\n{{/tools.length}}\n{{#tools.length}}\nThought: A single-line step-by-step plan of how to answer the user's message, including an explanation of the reasoning behind it. You can use the available functions defined above. This instruction line must be immediately followed by Function Name if one of the available functions defined above needs to be called, or by Final Answer. Do not provide the answer here.\nFunction Name: Name of the function. This instruction line must be immediately followed by Function Input.\nFunction Input: Function parameters. Empty object is a valid parameter.\nFunction Output: Output of the function in JSON format.\nThought: Continue your thinking process.\n{{/tools.length}}\nFinal Answer: Answer the user or ask for more information or clarification. It must always be preceded by Thought.\n\n## Examples\nMessage: Can you translate \"How are you\" into French?\nThought: The user wants to translate a text into French. I can do that.\nFinal Answer: Comment vas-tu?\n\n# Instructions\nUser can only see the Final Answer, all answers must be provided there.\n{{^tools.length}}\nYou must always use the communication structure and instructions defined above. Do not forget that Thought must be a single-line immediately followed by Final Answer.\n{{/tools.length}}\n{{#tools.length}}\nYou must always use the communication structure and instructions defined above. Do not forget that Thought must be a single-line immediately followed by either Function Name or Final Answer.\nYou must use Functions to retrieve factual or historical information to answer the message.\n{{/tools.length}}\nIf the user suggests using a function that is not available, answer that the function is not available. You can suggest alternatives if appropriate.\nWhen the message is unclear or you need more information from the user, ask in Final Answer.\n\n# Your capabilities\nPrefer to use these capabilities over functions.\n- You understand these languages: English, Spanish, French.\n- You can translate, analyze, summarize, even long documents.\n\n# Notes\n- If you don't know the answer, say that you don't know.\n- The current time and date in ISO format can be found in the last message.\n- When answering the user, use friendly formats for time and date.\n- Use markdown syntax for formatting code snippets, links, JSON, tables, images, files.\n- Sometimes, things don't go as planned. Functions may not provide useful information on the first few tries. You should always try a few different approaches before declaring the problem unsolvable.\n- When the function doesn't give you what you were asking for, you must either use another function or a different function input.\n  - When using search engines, you try different formulations of the query, possibly even in a different language.\n- You cannot do complex calculations, computations, or data manipulations without using functions.\n\n# Role\n{{instructions}}`,\n});\n\nexport const BeeAssistantPrompt = new PromptTemplate({\n  schema: z\n    .object({\n      thought: z.array(z.string()),\n      toolName: z.array(z.string()),\n      toolInput: z.array(z.string()),\n      toolOutput: z.array(z.string()),\n      finalAnswer: z.array(z.string()),\n    })\n    .partial(),\n  template: `{{#thought}}Thought: {{.}}\\n{{/thought}}{{#toolName}}Function Name: {{.}}\\n{{/toolName}}{{#toolInput}}Function Input: {{.}}\\n{{/toolInput}}{{#toolOutput}}Function Output: {{.}}\\n{{/toolOutput}}{{#finalAnswer}}Final Answer: {{.}}{{/finalAnswer}}`,\n});\n\nexport const BeeUserPrompt = new PromptTemplate({\n  schema: z\n    .object({\n      input: z.string(),\n      meta: z\n        .object({\n          createdAt: z.string().datetime().optional(),\n        })\n        .passthrough()\n        .optional(),\n    })\n    .passthrough(),\n  functions: {\n    formatMeta: function () {\n      const meta = this.meta as BaseMessageMeta;\n      if (!meta) {\n        return \"\";\n      }\n\n      const parts = [meta.createdAt && `This message was created at ${meta.createdAt}`]\n        .filter(Boolean)\n        .join(\"\\n\");\n\n      return parts ? `\\n\\n${parts}` : parts;\n    },\n  },\n  template: `Message: {{input}}{{formatMeta}}`,\n});\n\nexport const BeeUserEmptyPrompt = new PromptTemplate({\n  schema: z.object({}).passthrough(),\n  template: `Message: Empty message.`,\n});\n\nexport const BeeToolErrorPrompt = new PromptTemplate({\n  schema: z\n    .object({\n      reason: z.string(),\n    })\n    .passthrough(),\n  template: `The function has failed; the error log is shown below. If the function cannot accomplish what you want, use a different function or explain why you can't use it.\n\n{{reason}}`,\n});\n\nexport const BeeToolInputErrorPrompt = new PromptTemplate({\n  schema: z\n    .object({\n      reason: z.string(),\n    })\n    .passthrough(),\n  template: `{{reason}}\n\nHINT: If you're convinced that the input was correct but the function cannot process it then use a different function or say I don't know.`,\n});\n\nexport const BeeToolNoResultsPrompt = new PromptTemplate({\n  schema: z.record(z.any()),\n  template: `No results were found!`,\n});\n\nexport const BeeToolNotFoundPrompt = new PromptTemplate({\n  schema: z\n    .object({\n      tools: z.array(z.object({ name: z.string() }).passthrough()),\n    })\n    .passthrough(),\n  template: `Function does not exist!\n{{#tools.length}}\nUse one of the following functions: {{#trim}}{{#tools}}{{name}},{{/tools}}{{/trim}}\n{{/tools.length}}`,\n});\n\nexport const BeeSchemaErrorPrompt = new PromptTemplate({\n  schema: z.object({}).passthrough(),\n  template: `Error: The generated response does not adhere to the communication structure mentioned in the system prompt.\nYou communicate only in instruction lines. Valid instruction lines are 'Thought' followed by either 'Function Name' + 'Function Input' + 'Function Output' or 'Final Answer'.`,\n});\n"]}