Skip to content

Commit

Permalink
feat(client-bedrock-runtime): This release adds support for using Gua…
Browse files Browse the repository at this point in the history
…rdrails with the Converse and ConverseStream APIs.
  • Loading branch information
awstools committed Jun 18, 2024
1 parent fd9be05 commit 2bdad15
Show file tree
Hide file tree
Showing 5 changed files with 2,105 additions and 286 deletions.
147 changes: 145 additions & 2 deletions clients/client-bedrock-runtime/src/commands/ConverseCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
* a consistent interface that works with all models that
* support messages. This allows you to write code once and use it with different models.
* Should a model have unique inference parameters, you can also pass those unique parameters
* to the model. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/api-methods-run.html">Run inference</a> in the Bedrock User Guide.</p>
* to the model.</p>
* <p>For information about the Converse API, see <i>Use the Converse API</i> in the <i>Amazon Bedrock User Guide</i>.
* To use a guardrail, see <i>Use a guardrail with the Converse API</i> in the <i>Amazon Bedrock User Guide</i>.
* To use a tool with a model, see <i>Tool use (Function calling)</i> in the <i>Amazon Bedrock User Guide</i>
* </p>
* <p>For example code, see <i>Converse API examples</i> in the <i>Amazon Bedrock User Guide</i>.
* </p>
* <p>This operation requires permission for the <code>bedrock:InvokeModel</code> action. </p>
* @example
* Use a bare-bones client and the command you need to make an API call.
Expand Down Expand Up @@ -75,13 +81,23 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
* ],
* status: "success" || "error",
* },
* guardContent: { // GuardrailConverseContentBlock Union: only one key present
* text: { // GuardrailConverseTextBlock
* text: "STRING_VALUE", // required
* },
* },
* },
* ],
* },
* ],
* system: [ // SystemContentBlocks
* { // SystemContentBlock Union: only one key present
* text: "STRING_VALUE",
* guardContent: {// Union: only one key present
* text: {
* text: "STRING_VALUE", // required
* },
* },
* },
* ],
* inferenceConfig: { // InferenceConfiguration
Expand Down Expand Up @@ -112,6 +128,11 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
* },
* },
* },
* guardrailConfig: { // GuardrailConfiguration
* guardrailIdentifier: "STRING_VALUE", // required
* guardrailVersion: "STRING_VALUE", // required
* trace: "enabled" || "disabled",
* },
* additionalModelRequestFields: "DOCUMENT_VALUE",
* additionalModelResponseFieldPaths: [ // AdditionalModelResponseFieldPaths
* "STRING_VALUE",
Expand Down Expand Up @@ -153,11 +174,16 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
* // ],
* // status: "success" || "error",
* // },
* // guardContent: { // GuardrailConverseContentBlock Union: only one key present
* // text: { // GuardrailConverseTextBlock
* // text: "STRING_VALUE", // required
* // },
* // },
* // },
* // ],
* // },
* // },
* // stopReason: "end_turn" || "tool_use" || "max_tokens" || "stop_sequence" || "content_filtered", // required
* // stopReason: "end_turn" || "tool_use" || "max_tokens" || "stop_sequence" || "guardrail_intervened" || "content_filtered", // required
* // usage: { // TokenUsage
* // inputTokens: Number("int"), // required
* // outputTokens: Number("int"), // required
Expand All @@ -167,6 +193,123 @@ export interface ConverseCommandOutput extends ConverseResponse, __MetadataBeare
* // latencyMs: Number("long"), // required
* // },
* // additionalModelResponseFields: "DOCUMENT_VALUE",
* // trace: { // ConverseTrace
* // guardrail: { // GuardrailTraceAssessment
* // modelOutput: [ // ModelOutputs
* // "STRING_VALUE",
* // ],
* // inputAssessment: { // GuardrailAssessmentMap
* // "<keys>": { // GuardrailAssessment
* // topicPolicy: { // GuardrailTopicPolicyAssessment
* // topics: [ // GuardrailTopicList // required
* // { // GuardrailTopic
* // name: "STRING_VALUE", // required
* // type: "DENY", // required
* // action: "BLOCKED", // required
* // },
* // ],
* // },
* // contentPolicy: { // GuardrailContentPolicyAssessment
* // filters: [ // GuardrailContentFilterList // required
* // { // GuardrailContentFilter
* // type: "INSULTS" || "HATE" || "SEXUAL" || "VIOLENCE" || "MISCONDUCT" || "PROMPT_ATTACK", // required
* // confidence: "NONE" || "LOW" || "MEDIUM" || "HIGH", // required
* // action: "BLOCKED", // required
* // },
* // ],
* // },
* // wordPolicy: { // GuardrailWordPolicyAssessment
* // customWords: [ // GuardrailCustomWordList // required
* // { // GuardrailCustomWord
* // match: "STRING_VALUE", // required
* // action: "BLOCKED", // required
* // },
* // ],
* // managedWordLists: [ // GuardrailManagedWordList // required
* // { // GuardrailManagedWord
* // match: "STRING_VALUE", // required
* // type: "PROFANITY", // required
* // action: "BLOCKED", // required
* // },
* // ],
* // },
* // sensitiveInformationPolicy: { // GuardrailSensitiveInformationPolicyAssessment
* // piiEntities: [ // GuardrailPiiEntityFilterList // required
* // { // GuardrailPiiEntityFilter
* // match: "STRING_VALUE", // required
* // type: "ADDRESS" || "AGE" || "AWS_ACCESS_KEY" || "AWS_SECRET_KEY" || "CA_HEALTH_NUMBER" || "CA_SOCIAL_INSURANCE_NUMBER" || "CREDIT_DEBIT_CARD_CVV" || "CREDIT_DEBIT_CARD_EXPIRY" || "CREDIT_DEBIT_CARD_NUMBER" || "DRIVER_ID" || "EMAIL" || "INTERNATIONAL_BANK_ACCOUNT_NUMBER" || "IP_ADDRESS" || "LICENSE_PLATE" || "MAC_ADDRESS" || "NAME" || "PASSWORD" || "PHONE" || "PIN" || "SWIFT_CODE" || "UK_NATIONAL_HEALTH_SERVICE_NUMBER" || "UK_NATIONAL_INSURANCE_NUMBER" || "UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER" || "URL" || "USERNAME" || "US_BANK_ACCOUNT_NUMBER" || "US_BANK_ROUTING_NUMBER" || "US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER" || "US_PASSPORT_NUMBER" || "US_SOCIAL_SECURITY_NUMBER" || "VEHICLE_IDENTIFICATION_NUMBER", // required
* // action: "ANONYMIZED" || "BLOCKED", // required
* // },
* // ],
* // regexes: [ // GuardrailRegexFilterList // required
* // { // GuardrailRegexFilter
* // name: "STRING_VALUE",
* // match: "STRING_VALUE",
* // regex: "STRING_VALUE",
* // action: "ANONYMIZED" || "BLOCKED", // required
* // },
* // ],
* // },
* // },
* // },
* // outputAssessments: { // GuardrailAssessmentListMap
* // "<keys>": [ // GuardrailAssessmentList
* // {
* // topicPolicy: {
* // topics: [ // required
* // {
* // name: "STRING_VALUE", // required
* // type: "DENY", // required
* // action: "BLOCKED", // required
* // },
* // ],
* // },
* // contentPolicy: {
* // filters: [ // required
* // {
* // type: "INSULTS" || "HATE" || "SEXUAL" || "VIOLENCE" || "MISCONDUCT" || "PROMPT_ATTACK", // required
* // confidence: "NONE" || "LOW" || "MEDIUM" || "HIGH", // required
* // action: "BLOCKED", // required
* // },
* // ],
* // },
* // wordPolicy: {
* // customWords: [ // required
* // {
* // match: "STRING_VALUE", // required
* // action: "BLOCKED", // required
* // },
* // ],
* // managedWordLists: [ // required
* // {
* // match: "STRING_VALUE", // required
* // type: "PROFANITY", // required
* // action: "BLOCKED", // required
* // },
* // ],
* // },
* // sensitiveInformationPolicy: {
* // piiEntities: [ // required
* // {
* // match: "STRING_VALUE", // required
* // type: "ADDRESS" || "AGE" || "AWS_ACCESS_KEY" || "AWS_SECRET_KEY" || "CA_HEALTH_NUMBER" || "CA_SOCIAL_INSURANCE_NUMBER" || "CREDIT_DEBIT_CARD_CVV" || "CREDIT_DEBIT_CARD_EXPIRY" || "CREDIT_DEBIT_CARD_NUMBER" || "DRIVER_ID" || "EMAIL" || "INTERNATIONAL_BANK_ACCOUNT_NUMBER" || "IP_ADDRESS" || "LICENSE_PLATE" || "MAC_ADDRESS" || "NAME" || "PASSWORD" || "PHONE" || "PIN" || "SWIFT_CODE" || "UK_NATIONAL_HEALTH_SERVICE_NUMBER" || "UK_NATIONAL_INSURANCE_NUMBER" || "UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER" || "URL" || "USERNAME" || "US_BANK_ACCOUNT_NUMBER" || "US_BANK_ROUTING_NUMBER" || "US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER" || "US_PASSPORT_NUMBER" || "US_SOCIAL_SECURITY_NUMBER" || "VEHICLE_IDENTIFICATION_NUMBER", // required
* // action: "ANONYMIZED" || "BLOCKED", // required
* // },
* // ],
* // regexes: [ // required
* // {
* // name: "STRING_VALUE",
* // match: "STRING_VALUE",
* // regex: "STRING_VALUE",
* // action: "ANONYMIZED" || "BLOCKED", // required
* // },
* // ],
* // },
* // },
* // ],
* // },
* // },
* // },
* // };
*
* ```
Expand Down
Loading

0 comments on commit 2bdad15

Please sign in to comment.