Posts

APIGW + Lambda + DynamoDB

Image
  In this post, let see a demo application which is accessible by the users via API GW and the back end logic for the application is served by AWS lambda function. For persistent storage, we are using DynamoDB table. Lets start with DynamoDB table: I created a DynamoDB table by the name " employee_table ". Table has a primary key " employee_id " of datatype Number. So, any query to the table must be made through the key " employee_id ", else we need to scan the entire table. Let's add an item to the table from console. Now, we added an item to the table. Let's do the same and other action via API GW and Lambda Functions. Let's create a lambda function. One lambda function, based on the query parameter it invokes the function within the lambda. import json import boto 3 from botocore.exceptions import ClientError from decimal import Decimal from boto 3 .dynamodb.conditions import Key # Initialize the DynamoDB client dynamodb = boto 3 .resource(...

API Gateway with AWS S3

Image
  In this post, we will see how to read objects from S3 using AWS API GW. I already have a bucket with a JSON file. Here is the lambda function for reading the object from the bucket. In the below code, I have hardcoded the bucket name and the object name. import json import boto3 client = boto3.client( 's3' ) def lambda_handler ( event , context ):     response = client.get_object(     Bucket = 'demo-001-first' ,-------------> Bucket Name     Key = 'bucket1.json' ,------------------> Object Name )     # convert from streaming to bytes     data_bytes = response[ 'Body' ].read()     #bytes to string     data_strings = data_bytes.decode( "UTF-8" ) # convert from strings to dict     data_dict = json.loads(data_strings)     return {         'statusCode' : 200 ,         'body' : data_dict     } Finally, I have my API GW (REST) as belo...

Agentic AI - Series 5

Image
                                                              Hope you all having fun with our Agentic AI series. In this blog, we will see how to design a MAS (Multi Agent System) using CrewAI. CrewAI is a popular framework for building production grade AI systems.  We know that every agent needs Role. Goal. Backstory. Tasks. Tools MAS is nothing but completing a work with the help or collaboration of one more agents. Lets understand with a real life example. We are going to design a application which involves in recommending food for diabetic patients based on the given ingredients. To accomplish the task, we need a agent called " Chef ". Role - Experience Chef. Goal - Prepare delicious food based on the given ingredient. Backstory : You are an experienced chef and received accolades for preparing ...

Agentic AI - Series 4

Image
                                                                   In this blog, will how to create a simple agent using AI framework like Langchain with a simple LLM model  gpt-4o-mini. from langchain_openai import ChatOpenAI from langchain_core . tools import tool import os # Creating a tool @ tool def add_numbers ( x : int , y : int ) -> int :     "Add two numbers"     return x + y @tool is a decorator to define a tool. This is a simple tool to add 2 numbers. The below line creates a Langchain LLM wrapper around on the OpenAI chat mode 'gpt-4o-mini' # Binding the tool to a model llm = ChatOpenAI( model = "gpt-4o-mini" ).bind_tools([add_numbers]) response = llm .invoke( "What is 5 + 7?" ) When we print response, is the expected outcome? Is it 12. NO...

S3 - Directory Bucket

Image
  Directory buckets organize data hierarchically into directories as opposed to the flat storage structure of general purpose buckets. There aren't prefix limits for directory buckets, and individual directories can scale horizontally. Directory buckets support bucket creation in the following bucket location types : Availability Zone or Local Zone. For low latency use cases, you can create a directory bucket in a single Availability Zone to store data. Amazon S3 Express One Zone is a high-performance, single-zone Amazon S3 storage class that is purpose-built to deliver consistent, single-digit millisecond data access for your most latency-sensitive applications.  S3 Express One Zone is the lowest latency cloud-object storage class available today, with data access speeds up to 10x faster and with request costs 50 percent lower than S3 Standard. With S3 Express One Zone, your data is redundantly stored on multiple devices within a single Availability Zone.   You can ac...