Skip to content

Instantly share code, notes, and snippets.

View mikegc-aws's full-sized avatar

Mike Chambers mikegc-aws

  • Amazon Web Services
View GitHub Profile
@mikegc-aws
mikegc-aws / amazon_bedrock_inline_return_control.py
Last active February 27, 2025 13:51
Amzon Bedrock inline agent with return control. Run entire agent from one file. Session state stored in cloud.
import boto3
import json
import uuid
import datetime
from botocore.exceptions import ClientError
debug = False
def get_current_time():
"""Function to get the current time"""
@mikegc-aws
mikegc-aws / test_claude_3_7.ipynb
Last active February 25, 2025 02:20
Claude 3.7 Sonnet and Amazon Bedrock Converse API
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mikegc-aws
mikegc-aws / start_async_invoke.py
Created February 12, 2025 23:25
Generate a video using Luma AI Ray2 with the Amazon Bedrock start_async_invoke call.
# Get AWS Account
# Enable access to Luma AI Ray2 in Bedrock Console (Model access from menu on left)
# Run this Python code in an environment with access to AWS account.
import boto3, time
bedrock_runtime = boto3.client('bedrock-runtime', region_name='us-west-2')
prompt = "Sci-fi city at night slow pan across the skyline"
s3_uri = 's3://[your bucket for output files]'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mikegc-aws
mikegc-aws / lambda_hander.py
Created April 21, 2024 12:44
Sample Lambda Function for Agents for Amazon Bedrock
import json
import datetime
def lambda_handler(event, context):
agent = event['agent']
actionGroup = event['actionGroup']
function = event['function']
parameters = event.get('parameters', [])
@mikegc-aws
mikegc-aws / Spells_Embed.ipynb
Created March 28, 2024 11:09
A simple RAG demo from AWS re:Invent BOA308 2023
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mikegc-aws
mikegc-aws / L_Embed.ipynb
Created March 28, 2024 00:29
Simple example of how RAG works under the hood: https://www.youtube.com/watch?v=FQhksZ87Ncg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mikegc-aws
mikegc-aws / claude-3-streaming-response-amazon-bedrock-py
Last active March 18, 2024 23:00
Claude 3 Streaming Text Response and Processing with AWS Bedrock and Python Asyncio
import boto3
import json
from botocore.exceptions import ClientError
from pydantic import BaseModel
from typing import Literal, Dict, Optional
class ClaudeLLM(BaseModel):
modelId: Literal[
"anthropic.claude-3-sonnet-20240229-v1:0",
] = "anthropic.claude-3-sonnet-20240229-v1:0"
@mikegc-aws
mikegc-aws / app.js
Created March 14, 2024 03:58
Claude 3 Haiku - Amazon Bedrock - NodeJS text and image prompt.
// Adapted from code here: https://docs.aws.amazon.com/code-library/latest/ug/bedrock-runtime_code_examples_actions.html
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { fileURLToPath } from "url";
import {
AccessDeniedException,
BedrockRuntimeClient,