Skip to content
v2.273.0

Experimental

@aws-cdk/aws-bedrock-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

FunctionSchemaProps Struct ​

Properties for a function schema.

Example ​

ts
const actionGroupFunction = new lambda.Function(this, 'ActionGroupFunction', {
  runtime: lambda.Runtime.PYTHON_3_12,
  handler: 'index.handler',
  code: lambda.Code.fromAsset(path.join(__dirname, '../lambda/action-group')),
});

// Define a function schema with parameters
const functionSchema = new bedrock.FunctionSchema({
  functions: [
    {
      name: 'searchBooks',
      description: 'Search for books in the library catalog',
      parameters: {
        'query': {
          type: bedrock.ParameterType.STRING,
          required: true,
          description: 'The search query string',
        },
        'maxResults': {
          type: bedrock.ParameterType.INTEGER,
          required: false,
          description: 'Maximum number of results to return',
        },
        'includeOutOfPrint': {
          type: bedrock.ParameterType.BOOLEAN,
          required: false,
          description: 'Whether to include out-of-print books',
        }
      },
      requireConfirmation: bedrock.RequireConfirmation.DISABLED,
    },
    {
      name: 'getBookDetails',
      description: 'Get detailed information about a specific book',
      parameters: {
        'bookId': {
          type: bedrock.ParameterType.STRING,
          required: true,
          description: 'The unique identifier of the book',
        }
      },
      requireConfirmation: bedrock.RequireConfirmation.ENABLED,
    }
  ]
});

// Create an action group using the function schema
const actionGroup = new bedrock.AgentActionGroup({
  name: 'library-functions',
  description: 'Functions for interacting with the library catalog',
  executor: bedrock.ActionGroupExecutor.fromLambda(actionGroupFunction),
  functionSchema: functionSchema,
  enabled: true,
});

const agent = new bedrock.Agent(this, 'Agent', {
  foundationModel: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,
  instruction: 'You are a helpful and friendly agent that answers questions about literature.',
  actionGroups: [actionGroup],
});

Properties ​

functionsFunctionProps[]functionstyping.List[FunctionProps]functionsList<FunctionProps>FunctionsFunctionProps[]Functions*[]FunctionPropsrequired#
Functions defined in the schema.

Used as props by ​