Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce CodeInterpreter support and AutoPrepare in AgentDefinitionB… #26

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion lib/constructs/AgentDefinitionBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { aws_bedrock as bedrock } from 'aws-cdk-lib';
import { Construct } from "constructs";
import { USER_INPUT_ACTION_NAME, USER_INPUT_PARENT_SIGNATURE } from '../utilities/constants';
import { USER_INPUT_ACTION_NAME, USER_INPUT_PARENT_SIGNATURE, CODE_INTERPRETER_ACTION_NAME, CODE_INTERPRETER_PARENT_SIGNATURE } from '../utilities/constants';

export interface TagsConfig {
[key: string]: string;
@@ -209,6 +209,35 @@ export class AgentDefinitionBuilder extends Construct {
return this;
}

/**
* To allow agent to generate, run, and troubleshoot your application code in a secure test environment.
* We need to add an action group with the parentActionGroupSignature
* field set to AMAZON.CodeInterpreter.
* @returns AgentDefinitionBuilder object with a new action set.
*/
public withCodeInterpreter() {
const codeInterpreterAction: bedrock.CfnAgent.AgentActionGroupProperty = {
actionGroupName: CODE_INTERPRETER_ACTION_NAME,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take this as an optional input from the user. withCodeInterpreter(actionName: string)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this is required or exactly what you mean. Is this a blocker?

actionGroupState: "ENABLED",
parentActionGroupSignature: CODE_INTERPRETER_PARENT_SIGNATURE,
};

// Append the codeInterpreter AG to the agent definition.
this.agentDefinition = {
...this.agentDefinition,
actionGroups: [codeInterpreterAction]
MrIce-9 marked this conversation as resolved.
Show resolved Hide resolved
};
return this;
}

public enableAutoPrepare() {
this.agentDefinition = {
...this.agentDefinition,
autoPrepare: true
};
return this;
}

public withAdditionalProps(props: {[key: string]:any}) {
this.agentDefinition = {
...this.agentDefinition,
2 changes: 2 additions & 0 deletions lib/utilities/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export const USER_INPUT_ACTION_NAME = "UserInputAction";
export const USER_INPUT_PARENT_SIGNATURE = "AMAZON.UserInput";
export const CODE_INTERPRETER_ACTION_NAME = "CodeInterpreterAction";
export const CODE_INTERPRETER_PARENT_SIGNATURE = "AMAZON.CodeInterpreter";

export const AMAZON_BEDROCK_METADATA = 'AMAZON_BEDROCK_METADATA';
export const AMAZON_BEDROCK_TEXT_CHUNK = 'AMAZON_BEDROCK_TEXT_CHUNK';