{
  "typeName" : "AWS::Bedrock::Prompt",
  "description" : "Definition of AWS::Bedrock::Prompt Resource Type",
  "definitions" : {
    "PromptTemplateType" : {
      "type" : "string",
      "description" : "Prompt template type",
      "enum" : [ "TEXT", "CHAT" ]
    },
    "PromptVariant" : {
      "type" : "object",
      "description" : "Prompt variant",
      "properties" : {
        "Name" : {
          "type" : "string",
          "pattern" : "^([0-9a-zA-Z][_-]?){1,100}$",
          "description" : "Name for a variant."
        },
        "TemplateType" : {
          "$ref" : "#/definitions/PromptTemplateType"
        },
        "TemplateConfiguration" : {
          "$ref" : "#/definitions/PromptTemplateConfiguration"
        },
        "ModelId" : {
          "type" : "string",
          "maxLength" : 2048,
          "minLength" : 1,
          "pattern" : "^(arn:aws(-[^:]{1,12})?:(bedrock|sagemaker):[a-z0-9-]{1,20}:([0-9]{12})?:([a-z-]+/)?)?([a-zA-Z0-9.-]{1,63}){0,2}(([:][a-z0-9-]{1,63}){0,2})?(/[a-z0-9]{1,12})?$",
          "description" : "ARN or Id of a Bedrock Foundational Model or Inference Profile, or the ARN of a imported model, or a provisioned throughput ARN for custom models."
        },
        "InferenceConfiguration" : {
          "$ref" : "#/definitions/PromptInferenceConfiguration"
        },
        "GenAiResource" : {
          "$ref" : "#/definitions/PromptGenAiResource"
        },
        "AdditionalModelRequestFields" : {
          "$ref" : "#/definitions/AdditionalModelRequestFields"
        },
        "Metadata" : {
          "$ref" : "#/definitions/PromptMetadataList"
        }
      },
      "required" : [ "Name", "TemplateType", "TemplateConfiguration" ],
      "additionalProperties" : false
    },
    "TextPromptTemplateConfiguration" : {
      "type" : "object",
      "description" : "Configuration for text prompt template",
      "properties" : {
        "Text" : {
          "type" : "string",
          "maxLength" : 200000,
          "minLength" : 1,
          "description" : "Prompt content for String prompt template"
        },
        "TextS3Location" : {
          "$ref" : "#/definitions/TextS3Location"
        },
        "InputVariables" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/PromptInputVariable"
          },
          "maxItems" : 20,
          "minItems" : 0,
          "description" : "List of input variables",
          "insertionOrder" : true
        },
        "CachePoint" : {
          "$ref" : "#/definitions/CachePointBlock"
        }
      },
      "required" : [ ],
      "additionalProperties" : false
    },
    "ChatPromptTemplateConfiguration" : {
      "type" : "object",
      "description" : "Configuration for chat prompt template",
      "properties" : {
        "Messages" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/Message"
          },
          "minItems" : 0,
          "description" : "List of messages for chat prompt template",
          "insertionOrder" : true
        },
        "System" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/SystemContentBlock"
          },
          "minItems" : 0,
          "description" : "Configuration for chat prompt template",
          "insertionOrder" : true
        },
        "ToolConfiguration" : {
          "$ref" : "#/definitions/ToolConfiguration"
        },
        "InputVariables" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/PromptInputVariable"
          },
          "maxItems" : 20,
          "minItems" : 0,
          "description" : "List of input variables",
          "insertionOrder" : true
        }
      },
      "required" : [ "Messages" ],
      "additionalProperties" : false
    },
    "PromptTemplateConfiguration" : {
      "description" : "Prompt template configuration",
      "oneOf" : [ {
        "type" : "object",
        "title" : "Text",
        "properties" : {
          "Text" : {
            "$ref" : "#/definitions/TextPromptTemplateConfiguration"
          }
        },
        "required" : [ "Text" ],
        "additionalProperties" : false
      }, {
        "type" : "object",
        "title" : "Chat",
        "properties" : {
          "Chat" : {
            "$ref" : "#/definitions/ChatPromptTemplateConfiguration"
          }
        },
        "required" : [ "Chat" ],
        "additionalProperties" : false
      } ]
    },
    "TextS3Location" : {
      "type" : "object",
      "description" : "The identifier for the S3 resource.",
      "properties" : {
        "Bucket" : {
          "type" : "string",
          "maxLength" : 63,
          "minLength" : 3,
          "pattern" : "^[a-z0-9][\\.\\-a-z0-9]{1,61}[a-z0-9]$",
          "description" : "A bucket in S3"
        },
        "Key" : {
          "type" : "string",
          "maxLength" : 1024,
          "minLength" : 1,
          "description" : "A object key in S3"
        },
        "Version" : {
          "type" : "string",
          "maxLength" : 1024,
          "minLength" : 1,
          "description" : "The version of the the S3 object to use"
        }
      },
      "required" : [ "Bucket", "Key" ],
      "additionalProperties" : false
    },
    "ConversationRole" : {
      "type" : "string",
      "description" : "Conversation roles for the chat prompt",
      "enum" : [ "user", "assistant" ]
    },
    "ContentBlock" : {
      "description" : "Configuration for chat prompt template",
      "oneOf" : [ {
        "title" : "Text",
        "type" : "object",
        "properties" : {
          "Text" : {
            "type" : "string",
            "minLength" : 1,
            "description" : "Configuration for chat prompt template"
          }
        },
        "required" : [ "Text" ],
        "additionalProperties" : false
      }, {
        "title" : "CachePoint",
        "type" : "object",
        "properties" : {
          "CachePoint" : {
            "$ref" : "#/definitions/CachePointBlock"
          }
        },
        "required" : [ "CachePoint" ],
        "additionalProperties" : false
      } ]
    },
    "SystemContentBlock" : {
      "description" : "Configuration for chat prompt template",
      "oneOf" : [ {
        "title" : "Text",
        "type" : "object",
        "properties" : {
          "Text" : {
            "type" : "string",
            "minLength" : 1,
            "description" : "Configuration for chat prompt template"
          }
        },
        "required" : [ "Text" ],
        "additionalProperties" : false
      }, {
        "title" : "CachePoint",
        "type" : "object",
        "properties" : {
          "CachePoint" : {
            "$ref" : "#/definitions/CachePointBlock"
          }
        },
        "required" : [ "CachePoint" ],
        "additionalProperties" : false
      } ]
    },
    "Message" : {
      "type" : "object",
      "description" : "Chat prompt Message",
      "properties" : {
        "Role" : {
          "$ref" : "#/definitions/ConversationRole"
        },
        "Content" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/ContentBlock"
          },
          "minItems" : 1,
          "description" : "List of Content Blocks",
          "insertionOrder" : true
        }
      },
      "required" : [ "Role", "Content" ],
      "additionalProperties" : false
    },
    "ToolInputSchema" : {
      "description" : "Tool input schema",
      "oneOf" : [ {
        "type" : "object",
        "title" : "Json",
        "properties" : {
          "Json" : {
            "type" : "object"
          }
        },
        "description" : "Tool input schema json",
        "required" : [ "Json" ],
        "additionalProperties" : false
      } ]
    },
    "ToolSpecification" : {
      "type" : "object",
      "description" : "Tool specification",
      "properties" : {
        "Name" : {
          "type" : "string",
          "pattern" : "^[a-zA-Z][a-zA-Z0-9_]*$",
          "minLength" : 1,
          "maxLength" : 64,
          "description" : "Tool name"
        },
        "Description" : {
          "type" : "string",
          "minLength" : 1
        },
        "InputSchema" : {
          "$ref" : "#/definitions/ToolInputSchema"
        }
      },
      "required" : [ "Name", "InputSchema" ],
      "additionalProperties" : false
    },
    "Tool" : {
      "description" : "Tool details",
      "oneOf" : [ {
        "type" : "object",
        "title" : "ToolSpec",
        "properties" : {
          "ToolSpec" : {
            "$ref" : "#/definitions/ToolSpecification"
          }
        },
        "required" : [ "ToolSpec" ],
        "additionalProperties" : false
      }, {
        "title" : "CachePoint",
        "type" : "object",
        "properties" : {
          "CachePoint" : {
            "$ref" : "#/definitions/CachePointBlock"
          }
        },
        "required" : [ "CachePoint" ],
        "additionalProperties" : false
      } ]
    },
    "AutoToolChoice" : {
      "type" : "object",
      "description" : "Auto Tool choice",
      "additionalProperties" : false
    },
    "AnyToolChoice" : {
      "type" : "object",
      "description" : "Any Tool choice",
      "additionalProperties" : false
    },
    "SpecificToolChoice" : {
      "type" : "object",
      "description" : "Specific Tool choice",
      "properties" : {
        "Name" : {
          "type" : "string",
          "pattern" : "^[a-zA-Z][a-zA-Z0-9_]*$",
          "minLength" : 1,
          "maxLength" : 64,
          "description" : "Tool name"
        }
      },
      "required" : [ "Name" ],
      "additionalProperties" : false
    },
    "ToolChoice" : {
      "description" : "Tool choice",
      "oneOf" : [ {
        "title" : "Auto",
        "type" : "object",
        "properties" : {
          "Auto" : {
            "$ref" : "#/definitions/AutoToolChoice"
          }
        },
        "required" : [ "Auto" ],
        "additionalProperties" : false
      }, {
        "title" : "Any",
        "type" : "object",
        "properties" : {
          "Any" : {
            "$ref" : "#/definitions/AnyToolChoice"
          }
        },
        "required" : [ "Any" ],
        "additionalProperties" : false
      }, {
        "title" : "Tool",
        "type" : "object",
        "properties" : {
          "Tool" : {
            "$ref" : "#/definitions/SpecificToolChoice"
          }
        },
        "required" : [ "Tool" ],
        "additionalProperties" : false
      } ]
    },
    "ToolConfiguration" : {
      "type" : "object",
      "description" : "Tool configuration",
      "properties" : {
        "Tools" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/Tool"
          },
          "minItems" : 1,
          "description" : "List of Tools",
          "insertionOrder" : true
        },
        "ToolChoice" : {
          "$ref" : "#/definitions/ToolChoice"
        }
      },
      "required" : [ "Tools" ],
      "additionalProperties" : false
    },
    "PromptModelInferenceConfiguration" : {
      "type" : "object",
      "description" : "Prompt model inference configuration",
      "properties" : {
        "Temperature" : {
          "type" : "number",
          "maximum" : 1,
          "minimum" : 0,
          "description" : "Controls randomness, higher values increase diversity"
        },
        "TopP" : {
          "type" : "number",
          "maximum" : 1,
          "minimum" : 0,
          "description" : "Cumulative probability cutoff for token selection"
        },
        "MaxTokens" : {
          "type" : "number",
          "maximum" : 512000,
          "minimum" : 0,
          "description" : "Maximum length of output"
        },
        "StopSequences" : {
          "type" : "array",
          "items" : {
            "type" : "string"
          },
          "maxItems" : 4,
          "minItems" : 0,
          "description" : "List of stop sequences",
          "insertionOrder" : true
        }
      },
      "additionalProperties" : false
    },
    "PromptInferenceConfiguration" : {
      "description" : "Model inference configuration",
      "oneOf" : [ {
        "type" : "object",
        "title" : "Text",
        "properties" : {
          "Text" : {
            "$ref" : "#/definitions/PromptModelInferenceConfiguration"
          }
        },
        "required" : [ "Text" ],
        "additionalProperties" : false
      } ]
    },
    "PromptInputVariable" : {
      "type" : "object",
      "description" : "Input variable",
      "properties" : {
        "Name" : {
          "type" : "string",
          "pattern" : "^([0-9a-zA-Z][_-]?){1,100}$",
          "description" : "Name for an input variable"
        }
      },
      "additionalProperties" : false
    },
    "TagsMap" : {
      "type" : "object",
      "description" : "A map of tag keys and values",
      "patternProperties" : {
        "^[a-zA-Z0-9\\s._:/=+@-]*$" : {
          "type" : "string",
          "maxLength" : 256,
          "minLength" : 0,
          "pattern" : "^[a-zA-Z0-9\\s._:/=+@-]*$",
          "description" : "Value of a tag"
        }
      },
      "additionalProperties" : false
    },
    "PromptAgentResource" : {
      "description" : "Target Agent to invoke with Prompt",
      "type" : "object",
      "properties" : {
        "AgentIdentifier" : {
          "type" : "string",
          "maxLength" : 2048,
          "pattern" : "^arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:[0-9]{12}:agent-alias/[0-9a-zA-Z]{10}/[0-9a-zA-Z]{10}$",
          "description" : "Arn representation of the Agent Alias."
        }
      },
      "required" : [ "AgentIdentifier" ],
      "additionalProperties" : false
    },
    "PromptGenAiResource" : {
      "description" : "Target resource to invoke with Prompt",
      "oneOf" : [ {
        "type" : "object",
        "title" : "Agent",
        "properties" : {
          "Agent" : {
            "$ref" : "#/definitions/PromptAgentResource"
          }
        },
        "required" : [ "Agent" ],
        "additionalProperties" : false
      } ]
    },
    "CachePointBlock" : {
      "description" : "CachePointBlock",
      "type" : "object",
      "properties" : {
        "Type" : {
          "$ref" : "#/definitions/CachePointType"
        }
      },
      "required" : [ "Type" ],
      "additionalProperties" : false
    },
    "CachePointType" : {
      "description" : "CachePoint types for CachePointBlock",
      "type" : "string",
      "enum" : [ "default" ]
    },
    "AdditionalModelRequestFields" : {
      "type" : "object",
      "description" : "Contains model-specific configurations"
    },
    "PromptMetadataList" : {
      "type" : "array",
      "description" : "List of metadata to associate with the prompt variant.",
      "items" : {
        "$ref" : "#/definitions/PromptMetadataEntry"
      },
      "maxItems" : 50,
      "minItems" : 0,
      "insertionOrder" : true
    },
    "PromptMetadataEntry" : {
      "type" : "object",
      "description" : "Contains a key-value pair that defines a metadata tag and value to attach to a prompt variant.",
      "properties" : {
        "Key" : {
          "$ref" : "#/definitions/PromptMetadataKey"
        },
        "Value" : {
          "$ref" : "#/definitions/PromptMetadataValue"
        }
      },
      "required" : [ "Key", "Value" ],
      "additionalProperties" : false
    },
    "PromptMetadataKey" : {
      "type" : "string",
      "maxLength" : 128,
      "minLength" : 1,
      "pattern" : "^[a-zA-Z0-9\\s._:/=+@-]*$",
      "description" : "The key of a metadata tag for a prompt variant."
    },
    "PromptMetadataValue" : {
      "type" : "string",
      "maxLength" : 1024,
      "minLength" : 1,
      "pattern" : "^[a-zA-Z0-9\\s._:/=+@-]*$",
      "description" : "The value of a metadata tag for a prompt variant."
    }
  },
  "properties" : {
    "Arn" : {
      "type" : "string",
      "maxLength" : 2048,
      "minLength" : 1,
      "pattern" : "^(arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:[0-9]{12}:prompt/[0-9a-zA-Z]{10})$",
      "description" : "ARN of a prompt resource possibly with a version"
    },
    "CreatedAt" : {
      "type" : "string",
      "description" : "Time Stamp.",
      "format" : "date-time"
    },
    "DefaultVariant" : {
      "type" : "string",
      "pattern" : "^([0-9a-zA-Z][_-]?){1,100}$",
      "description" : "Name for a variant."
    },
    "Description" : {
      "type" : "string",
      "maxLength" : 200,
      "minLength" : 1,
      "description" : "Name for a prompt resource."
    },
    "Id" : {
      "type" : "string",
      "pattern" : "^[0-9a-zA-Z]{10}$",
      "description" : "Identifier for a Prompt"
    },
    "Name" : {
      "type" : "string",
      "pattern" : "^([0-9a-zA-Z][_-]?){1,100}$",
      "description" : "Name for a prompt resource."
    },
    "UpdatedAt" : {
      "type" : "string",
      "description" : "Time Stamp.",
      "format" : "date-time"
    },
    "Variants" : {
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/PromptVariant"
      },
      "maxItems" : 1,
      "minItems" : 0,
      "description" : "List of prompt variants",
      "insertionOrder" : true
    },
    "Tags" : {
      "$ref" : "#/definitions/TagsMap"
    },
    "CustomerEncryptionKeyArn" : {
      "type" : "string",
      "maxLength" : 2048,
      "minLength" : 1,
      "pattern" : "^arn:aws(|-cn|-us-gov):kms:[a-zA-Z0-9-]*:[0-9]{12}:key/[a-zA-Z0-9-]{36}$",
      "description" : "A KMS key ARN"
    },
    "Version" : {
      "type" : "string",
      "maxLength" : 5,
      "minLength" : 5,
      "pattern" : "^DRAFT$",
      "description" : "Draft Version."
    }
  },
  "required" : [ "Name" ],
  "readOnlyProperties" : [ "/properties/Arn", "/properties/CreatedAt", "/properties/Id", "/properties/UpdatedAt", "/properties/Version" ],
  "writeOnlyProperties" : [ "/properties/Variants/*/TemplateConfiguration/Text/TextS3Location" ],
  "primaryIdentifier" : [ "/properties/Arn" ],
  "handlers" : {
    "create" : {
      "permissions" : [ "bedrock:CreatePrompt", "bedrock:GetPrompt", "s3:GetObject", "s3:GetObjectVersion", "bedrock:TagResource", "bedrock:ListTagsForResource", "kms:GenerateDataKey", "kms:Decrypt" ]
    },
    "read" : {
      "permissions" : [ "bedrock:GetPrompt", "bedrock:ListTagsForResource", "kms:Decrypt" ]
    },
    "update" : {
      "permissions" : [ "bedrock:UpdatePrompt", "bedrock:GetPrompt", "s3:GetObject", "s3:GetObjectVersion", "bedrock:TagResource", "bedrock:UntagResource", "bedrock:ListTagsForResource", "kms:GenerateDataKey", "kms:Decrypt" ]
    },
    "delete" : {
      "permissions" : [ "bedrock:DeletePrompt", "bedrock:GetPrompt" ]
    },
    "list" : {
      "permissions" : [ "bedrock:ListPrompts" ]
    }
  },
  "tagging" : {
    "cloudFormationSystemTags" : false,
    "tagOnCreate" : true,
    "tagProperty" : "/properties/Tags",
    "tagUpdatable" : true,
    "taggable" : true,
    "permissions" : [ "bedrock:TagResource", "bedrock:UntagResource", "bedrock:ListTagsForResource" ]
  },
  "additionalProperties" : false
}