Skip to main content

Amazon Bedrock - Creating a AI Agent

Creating an AI agent using Amazon Bedrock involves configuring foundation models, defining tools, and deploying an agent capable of interacting with users and systems. Below is a step-by-step guide with visual references and a clear explanation.

Step 1: Understand Amazon Bedrock ArchitectureCore components:

  1. Foundation Model (FM) – Claude, Titan, Llama, etc.

  2. Agent – Orchestrates reasoning and actions

  3. Knowledge Base – Connects to your data (S3, PDFs, databases)

  4. Action Groups – Lambda functions for performing tasks

  5. Client Application – Web app, chatbot, or API

Step 2: Enable Amazon Bedrock

To enable the Amazon Bedrock - 
  1. Login to AWS Console

  2. Search → Amazon Bedrock

  3. Click → Model access

  4. Enable models like:

    • Claude (best for agents)

    • Titan

    • Llama

Step 3: Create Knowledge Base (Optional but Recommended)

A knowledge base allows agents to use your custom data. To create a Knowledge Base - 
Steps:
  1. Go to Bedrock Console

  2. Click → Knowledge Bases

  3. Click → Create knowledge base

  4. Select:

    • Data source → S3 bucket

    • Embedding model → Titan embeddings

  5. Sync data

Step 4: Create Lambda Function (Action)

Creating a basic lambda to say hello 😊
Example Lambda (Python):
def lambda_handler(event, context):
    user_input = event['inputText']

    if "hello" in user_input.lower():
        return {
            "message": "Hello! How can I help you?"
        }

    return {
        "message": "You said: {user_input}"
    }

Step 5: Create an Agent in Bedrock

1. Go to Bedrock Console

2. Click → Agents

3. Click → Create Agent

And fill in the details as below - 

Agent Name: MySupportAgent

Foundation Model: Claude 3 Sonnet or Claude 3 Haiku

Instructions (Important): "You are a helpful AI assistant that helps users answer questions and perform actions using provided tools."

Step 6: Add Action Group

Follow the steps below to add an Action Group:

  1. Open your agent

  2. Click → Add Action Group

  3. Select:

    • Lambda function created earlier

  4. Define schema

Example schema:

{
  "openapi": "3.0.0",
  "paths": {
    "/hello": {
      "post": {
        "operationId": "sayHello",
        "requestBody": {
          "content": {
            "application/json": {}
          }
        },
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    }
  }
}

Step 7: Test the Agent

Now the final step. It's time to test your agent. Follow the steps below - 
Steps:
  1. Click → Test Agent

  2. Enter message:

Hello agent

The agent will respond using model + Lambda.

Your agent must respond with a message such as "Hello! How can I help you?"

𝐼𝒻 π“Žπ‘œπ“Š π“Œπ‘œπ“Šπ“π’Ή 𝓁𝒾𝓀𝑒 π“‰π‘œ π’Έπ‘œπ“ƒπ“‰π“‡π’Ύπ’·π“Šπ“‰π‘’, 𝓅𝓁𝓏 π“Œπ“‡π’Ύπ“‰π‘’ & E𝓂𝒢𝒾𝓁 π“Žπ‘œπ“Šπ“‡ 𝒢𝓇𝓉𝒾𝒸𝓁𝑒 π“‰π‘œ π’Ήπ“‡π‘œπ’Ύπ’Ήπ’Άπ“‚π’Άπ“‡πŸ’πŸ’πŸ©@𝑔𝓂𝒢𝒾𝓁.π’Έπ‘œπ“‚.  π’΄π‘œπ“Š 𝒸𝒢𝓃 π“ˆπ‘’π‘’ π“Žπ‘œπ“Šπ“‡ 𝒢𝓇𝓉𝒾𝒸𝓁𝑒 𝒢𝓅𝓅𝑒𝒢𝓇𝒾𝓃𝑔 π‘œπ“ƒ 𝓉𝒽𝑒 𝓂𝒢𝒾𝓃 𝓅𝒢𝑔𝑒 𝒢𝓃𝒹 𝒽𝑒𝓁𝓅𝒾𝓃𝑔 π‘œπ“‰π’½π‘’π“‡π“ˆ. 

꧁༺ π»π‘œπ“…π‘’ π“‰π’½π’Ύπ“ˆ π“Œπ’Ύπ“π“ 𝒽𝑒𝓁𝓅 π“Žπ‘œπ“Š. 𝒦𝑒𝑒𝓅 π“‹π’Ύπ“ˆπ’Ύπ“‰π’Ύπ“ƒπ‘” π“‚π“Ž π’·π“π‘œπ‘” :) ༻꧂ 

Comments