This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider; | |
| import software.amazon.awssdk.core.document.Document; | |
| import software.amazon.awssdk.regions.Region; | |
| import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient; | |
| import software.amazon.awssdk.services.bedrockruntime.model.*; | |
| import java.util.concurrent.ExecutionException; | |
| import java.util.concurrent.atomic.AtomicReference; | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| User: | |
| I want to create a meta prompt for a large-language model like yourself to help me generate effective purpose-built prompts for specific use-cases. Here's my first draft: | |
| <PROMPT> | |
| You are an experienced prompt engineer with a very good understanding of how to use a Large-Language model like OpenAI GPT or Anthropic Claude. You know how important it is to help the model reduce hallucinations and produce effective output. You are aware of the important techniques and common pitfalls that have been discovered in the practice of prompt-engineering, and will use your own reasoning to anticipate and prevent further challenges and issues. One of your strengths is to help the model understand that the output must not sound like it has been written by an AI. Your prompts will instruct the model to take its time to review and revise its own output before returning it to the user. | |
| </PROMPT> | |
| Your first task is to improve or rethink the prompt to optimize it for its intended purpose. Create five variations, then t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Amazon; | |
| using Amazon.BedrockRuntime; | |
| using Amazon.BedrockRuntime.Model; | |
| using System; | |
| // Create a Bedrock Runtime client in the AWS Region of your choice. | |
| var client = new AmazonBedrockRuntimeClient(RegionEndpoint.USEast1); | |
| // Specify the model ID. We're using Llama 3 today, but it can be any | |
| // other text-based model on Amazon Bedrock. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const invokeBedrockAgent = async (prompt, sessionId) => { | |
| const region = "AWS_REGION"; | |
| const client = new BedrockAgentRuntimeClient({ region: region }); | |
| const agentId = "AGENT_ID"; | |
| const agentAliasId = "AGENT_ALIAS_ID"; | |
| sessionId = sessionId || crypto.randomUUID().replace(/-/g, "") | |
| try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import base64 | |
| import boto3 | |
| import json | |
| # Initialize the Amazon Bedrock runtime client | |
| client = self.client or boto3.client(service_name="bedrock-runtime", region_name="us-east-1") | |
| # Encode the image using base64 | |
| with open("path/to/you/image", "rb") as image_file: | |
| base64_image_data = base64.b64encode(image_file.read()).decode("utf8") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.nio.charset.StandardCharsets; | |
| import org.json.JSONObject; | |
| import software.amazon.awssdk.core.SdkBytes; | |
| import software.amazon.awssdk.regions.Region; | |
| import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient; | |
| import software.amazon.awssdk.services.bedrockruntime.model.InvokeModelRequest; | |
| import software.amazon.awssdk.services.bedrockruntime.model.InvokeModelResponse; | |
| public class Main { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import boto3 | |
| sqs = boto3.client('sqs') | |
| sns = boto3.client('sns') | |
| # Replace with your SNS topic ARN | |
| sns_topic_arn = 'YOUR_SNS_TOPIC_ARN' | |
| def lambda_handler(event, context): | |
| # Receive a message from the SQS queue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import boto3 | |
| # Set up SQS resource with AWS credentials | |
| sqs = boto3.resource( | |
| 'sqs', | |
| aws_access_key_id='YOUR_AWS_ACCESS_KEY_ID', | |
| aws_secret_access_key='YOUR_AWS_SECRET_ACCESS_KEY', | |
| region_name='YOUR_AWS_REGION' | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import random | |
| print('Fulfillment service') | |
| def lambda_handler(event, context): | |
| print('----------') | |
| if 'EventSource' in event['Records'][0] and event['Records'][0]['EventSource'] == 'aws:sns': | |
| print('Processing SNS message...') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Effect": "Allow", | |
| "Action": [ | |
| "ce:GetCostAndUsage", | |
| "ce:GetCostAndUsageWithResources", | |
| "ce:GetCostForecast" | |
| ], |