{"version":3,"file":"ConversationType.mjs","sources":["../../../src/ai/ConversationType.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { allowForConversations } from '../Authorization';\nimport { brand } from '../util';\nexport const brandName = 'conversationCustomOperation';\n/**\n * Define a data tool to be used within an AI conversation route.\n *\n * @remarks\n *\n * Data tools can use a model generated list query or a custom query.\n * The tool's name must satisfy the following requirements:\n * - Be unique across all tools for a given conversation.\n * - Length must be between 1 and 64 characters.\n * - Must start with a letter.\n * - Must contain only letters, numbers, and underscores.\n *\n * The tool's `name` and `description` are used by the LLM to help it understand\n * the tool's purpose.\n *\n * @example\n *\n * realtorChat: a.conversation({\n *   aiModel: a.ai.model('Claude 3 Haiku'),\n *   systemPrompt: 'You are a helpful real estate assistant',\n *   tools: [\n *     // Data tools can use a model generated list query.\n *     a.ai.dataTool({\n *       name: 'get_listed_properties',\n *       description: 'Get properties currently listed for sale',\n *       model: a.model('RealEstateProperty'),\n *       modelOperation: 'list',\n *     }),\n *     // Data tools can also use a custom query.\n *     a.ai.dataTool({\n *       name: 'get_oncall_realtor',\n *       description: 'Get the oncall realtor',\n *       query: a.query('getOnCallRealtor'),\n *     }),\n *   ],\n * })\n * @returns a data tool definition\n */\nexport function dataTool(input) {\n    return input;\n}\nfunction _conversation(input) {\n    const data = {\n        authorization: [],\n    };\n    const builder = {\n        authorization(callback) {\n            const rules = callback(allowForConversations);\n            data.authorization = Array.isArray(rules) ? rules : [rules];\n            return this;\n        },\n    };\n    return {\n        ...brand(brandName),\n        ...input,\n        ...builder,\n        data,\n    };\n}\n/**\n * Define an AI conversation route which enables multi-turn conversation APIs for interacting with specified AI model.\n * @example\n * realtorChat: a.conversation({\n *   aiModel: { resourcePath },\n *   systemPrompt: 'You are a helpful real estate assistant',\n * })\n * @returns a conversation route definition\n */\nexport function conversation(input) {\n    return _conversation(input);\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAGY,MAAC,SAAS,GAAG;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,QAAQ,CAAC,KAAK,EAAE;AAChC,IAAI,OAAO,KAAK;AAChB;AACA,SAAS,aAAa,CAAC,KAAK,EAAE;AAC9B,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,aAAa,EAAE,EAAE;AACzB,KAAK;AACL,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,aAAa,CAAC,QAAQ,EAAE;AAChC,YAAY,MAAM,KAAK,GAAG,QAAQ,CAAC,qBAAqB,CAAC;AACzD,YAAY,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC;AACvE,YAAY,OAAO,IAAI;AACvB,QAAQ,CAAC;AACT,KAAK;AACL,IAAI,OAAO;AACX,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC;AAC3B,QAAQ,GAAG,KAAK;AAChB,QAAQ,GAAG,OAAO;AAClB,QAAQ,IAAI;AACZ,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,YAAY,CAAC,KAAK,EAAE;AACpC,IAAI,OAAO,aAAa,CAAC,KAAK,CAAC;AAC/B;;;;"}