Problem/Motivation

AWS Bedrock support guardrails to set specific policies for model output. There does not appear to be away to set these as invoke parameters as part of the AWS Bedrock AI provider.

Proposed resolution

Allow configuration of invoke parameters as part of the Bedrock provider configuration.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

adam-delaney created an issue. See original summary.

adam-delaney’s picture

I've been able to invoke a model that enforces a guardrail via IAM policy by hardcoding `guardrailConfig` array in the payload variable within the chat() method of the provider plugin. I'm not sure how we can set this dynamically using some type of Drupal config. My initial thought would be to provide configuration for the AWS Bedrock provider settings, so that the guardrails could be applied every time we call converse on the AWS Bedrock runtime client.

adam-delaney’s picture

I've opened a MR that allows altering the chat payload, https://git.drupalcode.org/issue/ai_provider_aws_bedrock-3562254/-/tree/....

You can alter the payload like this to set Guardrails:

function HOOK_ai_provider_aws_bedrock_chat_payload_alter(array &$payload): void {
  $payload['guardrailConfig'] = [
    'guardrailIdentifier' => 'GUARDRAIL ARN',
    'guardrailVersion' => 'VERSION',
  ];
}
jaydub’s picture

Status: Active » Needs review
fraserthompson’s picture

AI module has this now https://www.drupal.org/project/ai/issues/3518963 so maybe it'd be better to implement this as a AiGuardrail plugin?

jaydub’s picture

In this case, the guardrail is something defined on the AWS Bedrock side of things and does not directly involve Drupal, so I don't think the AiGuardrail plugin in the latest version of the AI module would work in this case. The AWS Bedrock defined guardrails here are organization wide rules and are applied to calls going to AWS Bedrock whether from Drupal AI module calls as the requestor, or other sources. So the ability to be able to apply those Bedrock guardrails when using the Bedrock Drupal AI provider is still needed.