Coder Social home page Coder Social logo

bedrock-agent's Introduction

Bedrock Agent Tutorial

Refer YouTube Video: https://www.youtube.com/watch?v=6O9DqCrInvw

BytesCommerce/BytesCommerceFunction.py
This lambda function is configured in Action Group.

BytesCommerce/BytesCommerceSchema.json
This is the Open API Schema configured in Action Group.

BytesCommerce/kb-data
Here you will find two (knowledge base) files used in the demo:
ProductCatalog.csv, ProductDescriptions.pdf

BytesCommerce/InvokeAgentBytesCommerce.py
This is a lambda function to invoke the BytesCommerce Agent programmatically.
If you don't plan to invoke the Agent programmatically, you can ignore it.
You must use a version of boto3 that supports bedrock-agent-runtime (eg. version 1.34.49).

Check boto3 version in a lambda function:
print(boto3.__version__)
print(botocore.__version__)

To use latest version of boto3 with your lambda function (assuming it is not available via AWS Console by default) you can follow these steps to include it via a Layer:

  1. Open Cloud Shell in AWS Console OR any shell/command-line environment with AWS configured.
  2. Create a new directory:
    LIB_DIR=boto3-mylayer/python
    mkdir -p $LIB_DIR
  3. Install the boto3 library to LIB_DIR by running the following command:
    pip3 install boto3 -t $LIB_DIR
  4. Zip all the dependencies to /tmp/boto3-mylayer.zip by running the following command:
    cd boto3-mylayer
    zip -r /tmp/boto3-mylayer.zip .
  5. Publish the layer by running the following command:
    aws lambda publish-layer-version --layer-name boto3-mylayer --zip-file fileb:///tmp/boto3-mylayer.zip
    The command returns the new layer's Amazon Resource Name (ARN), similar to the following one:
    arn:aws:lambda:region:$ACC_ID:layer:boto3-mylayer:1
  6. Once the layer is created, you can go to AWS Console > lambda function (InvokeAgentBytesCommerce) and attach the layer to it.
    OR use the following command to attach the layer to your lambda function.
    aws lambda update-function-configuration --function-name <name-of-your-lambda i.e InvokeAgentBytesCommerce> --layers <layer ARN as seen above>

Within your lambda function you can print boto3 version to verify:
print(boto3.__version__)
print(botocore.__version__)

How to gain access to Foundation Model
In AWS Console > Bedrock > Foundation Models > Base Model > Model Access > Manage Model Access > Select the Models you need access to and hit Save.

Cleanup
Delete/release all resources related to Bedrock Agent - If you no longer need the Agent

  • Agent (Actions and Knowledge Bases)
  • OpenSearch Serverless Collection - This must be explicitly deleted. Although it is created automatically during Knowledge Base Creation - it doesn't get deleted automatically on Knowledge Base deletion
  • Unsubscribe(Remove Access) to any AWS Bedrock Models (for eg. Anthropic Claude)
  • Lambda function(s) & S3 bucket(s)
  • Any other related resources you may have created.

bedrock-agent's People

Contributors

architecturebytes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.