Sanchit Dilip Jain/Amazon Bedrock Agent - Overview πŸ”

Created Fri, 17 May 2024 12:00:00 +0000 Modified Sun, 07 Jul 2024 20:06:17 +0000
682 Words 3 min

Amazon Bedrock Agent - Overview

Introduction

  1. What is Amazon Bedrock?

    • Amazon Bedrock is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies like Stability AI, Anthropic, and Meta via a single API. It also provides the broad capabilities needed to build Generative AI applications with security, privacy, and responsible AI.
    • Since Amazon Bedrock is serverless, you don’t have to manage any infrastructure, and you can securely integrate and deploy Generative AI capabilities into your applications using the AWS services you already know.
  2. What Agents for Amazon Bedrock?

    • Agents for Amazon Bedrock help you build Generative AI assistants that break down user-requested tasks into multiple steps. They use the developer-provided instruction to create an orchestration plan and then carry out the plan by invoking APIs and accessing Knowledge Bases to provide a final response to the end user.

Demo

  • In this demo, we will create an AWS Solutions Architect Agent that will use our Knowledge Base to answer AWS questions. We will also create an action to read records from a database.

  • LLMs are not built for data analytics capabilities; it’s better to build a specialized tool that the Agent can use.

    • Prerequisite:

    • Building an Amazon Bedrock Agent:

      • To start with the agent, open the Agents console, then choose Create Agent. Here are the steps to create our agent:

      • Enter name and description. Here is what you can use. Leave everything else as default. Then press Create

      • Agent details - Select Claude 3 Sonnet for the model, then provide the following instructions:

      You are an expert AWS Certified Solutions Architect. Your role is to help customers understand best practices on building on AWS.

      • Now click Save at the top.

    • Action groups:

      • An action is a task that the agent can perform automatically by making API calls to a Lambda Function. An action group defines a set of actions. An OpenAPI schema defines the API for all the actions in the group. Here, we have a predefined action that will read records from a database.

      • To create one, click Add in the Action Groups section. Enter the following:

        • Enter Action group name: data-processing. and description: Actions to process data.

        • Action group type: Select Define with API schemas.

        • Action group invocation: Select an existing Lambda function -> data_process_action

        • Action group schema: Select an existing API schema. Select Browse S3, then select the bucket with openapibucket in the name, then select the agent_bedrock_schema.json file, then press Choose. Then press Create

    • Knowledge bases:

      • Now we can add the Knowledge Base we created earlier. Click Add in the Knowledge bases section, then select the one we made earlier. You can use the following for the instructions:

      Query the AWS Well-Architected Framework to answer the customer's question.

      • Click Add to finish
    • Using the Agent

      • To test the Agent in the console, click the Prepare button in the chat window. Once ready, you can begin to query the Agent.

      • For example, What can you tell me about S3 buckets?. Once the Agent is finished responding, you can click Show trace to see the agent’s steps to get the answer.

    • Test the agent

      • We can test our action to read records from a database by asking a question such as Can you help with the data processing task of getting the number of records in the production database?

    • Agents API: We can invoke your agent through the API.

      • Head back to the editor and open agent_rag.py.

      • Update AGENT_ID with the ID for your Agent. It is in the Agent overview section for the Agent you created.

      • Run the code with agent_rag.py.

      • Try playing with QUERY on line 6 to see what type of responses you get.

Resources

  • Visit this page to find the latest documentation.