From 6ad77168f50b39634f3469801e7a0fe94ed65c51 Mon Sep 17 00:00:00 2001 From: jonathan343 Date: Sat, 24 Oct 2026 18:17:41 -0400 Subject: [PATCH] Remove old developer guide --- README.md | 2 + dev-guide/README.md | 19 --- dev-guide/best-practices.md | 11 -- dev-guide/compliance-validation.md | 15 --- dev-guide/configuring.md | 10 -- dev-guide/credential-providers.md | 37 ------ dev-guide/data-protection.md | 14 -- dev-guide/disaster-recovery-resiliency.md | 7 - dev-guide/doc-history.md | 7 - dev-guide/getting-started.md | 10 -- dev-guide/index.md | 31 ----- dev-guide/installing.md | 43 ------- dev-guide/region.md | 42 ------ dev-guide/security.md | 14 -- dev-guide/service-clients.md | 25 ---- dev-guide/simple-app.md | 149 ---------------------- dev-guide/using.md | 6 - dev-guide/what-is-the-python-sdk.md | 27 ---- 18 files changed, 2 insertions(+), 467 deletions(-) delete mode 100644 dev-guide/README.md delete mode 100644 dev-guide/best-practices.md delete mode 100644 dev-guide/compliance-validation.md delete mode 100644 dev-guide/configuring.md delete mode 100644 dev-guide/credential-providers.md delete mode 100644 dev-guide/data-protection.md delete mode 100644 dev-guide/disaster-recovery-resiliency.md delete mode 100644 dev-guide/doc-history.md delete mode 100644 dev-guide/getting-started.md delete mode 100644 dev-guide/index.md delete mode 100644 dev-guide/installing.md delete mode 100644 dev-guide/region.md delete mode 100644 dev-guide/security.md delete mode 100644 dev-guide/service-clients.md delete mode 100644 dev-guide/simple-app.md delete mode 100644 dev-guide/using.md delete mode 100644 dev-guide/what-is-the-python-sdk.md diff --git a/README.md b/README.md index 23f49ef3..4f70529c 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ > > **For production deployments, use [Boto3](https://github.com/boto/boto3)**: the established, generally available AWS SDK for Python with full coverage of all AWS services. +[API Reference](https://docs.aws.amazon.com/sdk-for-python/v4/reference/) | [Developer Guide](https://docs.aws.amazon.com/sdk-for-python/v4/guide/welcome.html) + This repository contains the next-generation AWS SDK for Python v4, rebuilt from the ground up with an async-first, modular architecture. These new clients allow you to interact with select AWS services using Python's native `async`/`await` diff --git a/dev-guide/README.md b/dev-guide/README.md deleted file mode 100644 index 32f0a807..00000000 --- a/dev-guide/README.md +++ /dev/null @@ -1,19 +0,0 @@ -## Experimental Amazon Bedrock Runtime client for Python -[![Apache 2 licensed][apache-badge]][apache-url] - -[apache-badge]: https://img.shields.io/badge/license-APACHE2-blue.svg -[apache-url]: https://github.com/aws/aws-sdk-python/blob/main/LICENSE - -This directory contains the Developer Guide for the experimental Amazon -Bedrock Runtime client for Python. - -[Developer Guide](index.md) - -## Security - -See [CONTRIBUTING](../CONTRIBUTING.md#security-issue-notifications) for more information. - -## License - -This project is licensed under the Apache-2.0 License. - diff --git a/dev-guide/best-practices.md b/dev-guide/best-practices.md deleted file mode 100644 index 6296604f..00000000 --- a/dev-guide/best-practices.md +++ /dev/null @@ -1,11 +0,0 @@ -# Best practices for using the experimental Amazon Bedrock Runtime client for Python - -The following are best practices for using the experimental Amazon Bedrock Runtime client for Python. - -## Reuse SDK clients when possible - -Depending on how an SDK client is constructed, creating a new client may result in each client maintaining its own HTTP connection pools, identity caches, and so on. We recommend sharing a client when possible to avoid the overhead of expensive resource creation. - -## Use virtual environments - -This is a general Python development recommendation, but it's a good one that bears repeating. It's good to use a separate [virtual environment](https://docs.python.org/3/library/venv.html) for every project you work on. This helps to maintain version compatibility with your dependencies without risking breaking other applications using the same libraries and packages. \ No newline at end of file diff --git a/dev-guide/compliance-validation.md b/dev-guide/compliance-validation.md deleted file mode 100644 index b551b349..00000000 --- a/dev-guide/compliance-validation.md +++ /dev/null @@ -1,15 +0,0 @@ -# Compliance validation for experimental Amazon Bedrock Runtime client for Python - -To learn whether an AWS service is within the scope of specific compliance programs, see [AWS services in Scope by Compliance Program](https://aws.amazon.com/compliance/services-in-scope/) and choose the compliance program that you are interested in. For general information, see [AWS Compliance Programs](https://aws.amazon.com/compliance/programs/). - -You can download third-party audit reports using AWS Artifact. For more information, see [Downloading Reports in AWS Artifact](https://docs.aws.amazon.com/artifact/latest/ug/downloading-documents.html). - -Your compliance responsibility when using AWS services is determined by the sensitivity of your data, your company's compliance objectives, and applicable laws and regulations. AWS provides the following resources to help with compliance: -+ [Security Compliance & Governance](https://aws.amazon.com/solutions/security/security-compliance-governance/) – These solution implementation guides discuss architectural considerations and provide steps for deploying security and compliance features. -+ [HIPAA Eligible Services Reference](https://aws.amazon.com/compliance/hipaa-eligible-services-reference/) – Lists HIPAA eligible services. Not all AWS services are HIPAA eligible. -+ [AWS Compliance Resources](https://aws.amazon.com/compliance/resources/) – This collection of workbooks and guides might apply to your industry and location. -+ [AWS Customer Compliance Guides](https://d1.awsstatic.com/whitepapers/compliance/AWS_Customer_Compliance_Guides.pdf) – Understand the shared responsibility model through the lens of compliance. The guides summarize the best practices for securing AWS services and map the guidance to security controls across multiple frameworks including National Institute of Standards and Technology NIST), Payment Card Industry Security Standards Council PCI), and International Organization for Standardization ISO)). -+ [Evaluating Resources with Rules](https://docs.aws.amazon.com/config/latest/developerguide/evaluate-config.html) in the *AWS Config Developer Guide* – The AWS Config service assesses how well your resource configurations comply with internal practices, industry guidelines, and regulations. -+ [AWS Security Hub](https://docs.aws.amazon.com/securityhub/latest/userguide/what-is-securityhub.html) – This AWS service provides a comprehensive view of your security state within AWS. Security Hub uses security controls to evaluate your AWS resources and to check your compliance against security industry standards and best practices. For a list of supported services and controls, see [Security Hub controls reference](https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-controls-reference.html). -+ [Amazon GuardDuty](https://docs.aws.amazon.com/guardduty/latest/ug/what-is-guardduty.html) – This AWS service detects potential threats to your AWS accounts, workloads, containers, and data by monitoring your environment for suspicious and malicious activities. GuardDuty can help you address various compliance requirements, like PCI DSS, by meeting intrusion detection requirements mandated by certain compliance frameworks. -+ [AWS Audit Manager](https://docs.aws.amazon.com/audit-manager/latest/userguide/what-is.html) – This AWS service helps you continuously audit your AWS usage to simplify how you manage risk and compliance with regulations and industry standards. \ No newline at end of file diff --git a/dev-guide/configuring.md b/dev-guide/configuring.md deleted file mode 100644 index f9369597..00000000 --- a/dev-guide/configuring.md +++ /dev/null @@ -1,10 +0,0 @@ -# Configuring the experimental Amazon Bedrock Runtime client for Python - -Learn how to configure the experimental Amazon Bedrock Runtime client for Python. You must establish how your code authenticates with AWS when you develop with AWS services. You must also set the AWS Region you want to use. - -The [AWS SDKs and Tools Reference Guide](https://docs.aws.amazon.com/sdkref/latest/guide/) also contains other foundational concepts common among many of the AWS SDKs. - -**Topics** -+ [AWS Region](region.md) -+ [Credential providers](credential-providers.md) -+ [Service clients](service-clients.md) \ No newline at end of file diff --git a/dev-guide/credential-providers.md b/dev-guide/credential-providers.md deleted file mode 100644 index 15904d7f..00000000 --- a/dev-guide/credential-providers.md +++ /dev/null @@ -1,37 +0,0 @@ -# Using experimental Amazon Bedrock Runtime client for Python credential providers - -To make requests to AWS using the experimental Amazon Bedrock Runtime client for Python, the SDK uses cryptographically-signed credentials issued by AWS. At runtime, the SDK retrieves configuration values for credentials by checking several locations. - -For guided options for getting started on AWS authentication for your project, see [Authentication and access](https://docs.aws.amazon.com/sdkref/latest/guide/access.html) in the *AWS SDKs and Tools Reference Guide*. - -## Credentials identity resolvers provided by the experimental Amazon Bedrock Runtime client for Python - -`ContainerCredentialsResolver` -Obtains credentials from a container credential service such as the one provided with Amazon Elastic Container Service (Amazon ECS) and Amazon Elastic Kubernetes Service (Amazon EKS). - -`EnvironmentCredentialsResolver` -Resolves credentials found in the environment variables `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN`. - -`IMDSCredentialsResolver` -Obtains credentials from an Amazon EC2 instance's metadata using the Instance Metadata Service (IMDS). - -`StaticCredentialsResolver` -Uses static credentials specified in the form of an IAM access key ID, secret access key, and possibly a session token. - -For details on AWS credential provider configuration settings, see [Standardized credential providers](https://docs.aws.amazon.com/sdkref/latest/guide/standardized-credentials.html) in the *Settings reference* of the *AWS SDKs and Tools Reference Guide*. - -**Note** -Not all credential providers are supported yet by the experimental Amazon Bedrock Runtime client for Python. Only those listed above can be used at this time. - -## Using a specific credentials identity resolver - -To use a specific credentials identity resolver, set the `aws_credentials_identity_resolver` property on the service client's `Config` object to an instance of the credentials identity resolver class you want to use. The following example specifically uses the `EnvironmentCredentialsResolver()`, which fetches credentials from the standard environment variables `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN`. - -``` - service_client = BedrockRuntimeClient( - config=Config( - aws_credentials_identity_resolver=EnvironmentCredentialsResolver(), - region = "us-east-1", - ) - ) -``` diff --git a/dev-guide/data-protection.md b/dev-guide/data-protection.md deleted file mode 100644 index 5b613fe1..00000000 --- a/dev-guide/data-protection.md +++ /dev/null @@ -1,14 +0,0 @@ -# Data protection in the experimental Amazon Bedrock Runtime client for Python - -The AWS [shared responsibility model](https://aws.amazon.com/compliance/shared-responsibility-model/) applies to data protection in experimental Amazon Bedrock Runtime client for Python. As described in this model, AWS is responsible for protecting the global infrastructure that runs all of the AWS Cloud. You are responsible for maintaining control over your content that is hosted on this infrastructure. You are also responsible for the security configuration and management tasks for the AWS services that you use. For more information about data privacy, see the [Data Privacy FAQ](https://aws.amazon.com/compliance/data-privacy-faq/). For information about data protection in Europe, see the [AWS Shared Responsibility Model and GDPR](https://aws.amazon.com/blogs/security/the-aws-shared-responsibility-model-and-gdpr/) blog post on the *AWS Security Blog*. - -For data protection purposes, we recommend that you protect AWS account credentials and set up individual users with AWS IAM Identity Center or AWS Identity and Access Management (IAM). That way, each user is given only the permissions necessary to fulfill their job duties. We also recommend that you secure your data in the following ways: -+ Use multi-factor authentication (MFA) with each account. -+ Use SSL/TLS to communicate with AWS resources. We require TLS 1.2 and recommend TLS 1.3. -+ Set up API and user activity logging with AWS CloudTrail. For information about using CloudTrail trails to capture AWS activities, see [Working with CloudTrail trails](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-trails.html) in the *AWS CloudTrail User Guide*. -+ Use AWS encryption solutions, along with all default security controls within AWS services. -+ Use advanced managed security services such as Amazon Macie, which assists in discovering and securing sensitive data that is stored in Amazon S3. -+ If you require FIPS 140-3 validated cryptographic modules when accessing AWS through a command line interface or an API, use a FIPS endpoint. For more information about the available FIPS endpoints, see [Federal Information Processing Standard (FIPS) 140-3](https://aws.amazon.com/compliance/fips/). - -We strongly recommend that you never put confidential or sensitive information, such as your customers' email addresses, into tags or free-form text fields such as a **Name** field. This includes when you work with Amazon Bedrock Runtime client or other AWS services using the console, API, AWS CLI, or AWS SDKs. Any data that you enter into tags or free-form text fields used for names may be used for billing or diagnostic logs. If you provide a URL to an external server, we strongly recommend that you do not include credentials information in the URL to validate your request to that server. - diff --git a/dev-guide/disaster-recovery-resiliency.md b/dev-guide/disaster-recovery-resiliency.md deleted file mode 100644 index 886b4c92..00000000 --- a/dev-guide/disaster-recovery-resiliency.md +++ /dev/null @@ -1,7 +0,0 @@ -# Resilience in the experimental Amazon Bedrock Runtime client for Python - -The AWS global infrastructure is built around AWS Regions and Availability Zones. AWS Regions provide multiple physically separated and isolated Availability Zones, which are connected with low-latency, high-throughput, and highly redundant networking. With Availability Zones, you can design and operate applications and databases that automatically fail over between zones without interruption. Availability Zones are more highly available, fault tolerant, and scalable than traditional single or multiple data center infrastructures. - -For more information about AWS Regions and Availability Zones, see [AWS Global Infrastructure](https://aws.amazon.com/about-aws/global-infrastructure/). - -In addition to the AWS global infrastructure, Amazon Bedrock Runtime client offers several features to help support your data resiliency and backup needs. \ No newline at end of file diff --git a/dev-guide/doc-history.md b/dev-guide/doc-history.md deleted file mode 100644 index 2f7168b7..00000000 --- a/dev-guide/doc-history.md +++ /dev/null @@ -1,7 +0,0 @@ -# Document history for the experimental Amazon Bedrock Runtime client for Python Developer Guide - -The following table describes the documentation releases for Amazon Bedrock Runtime client. - -| Change | Description | Date | -| --- |--- |--- | -| [Initial release](#doc-history) | Initial release of the experimental Amazon Bedrock Runtime client for Python Developer Guide | April 8, 2025 | \ No newline at end of file diff --git a/dev-guide/getting-started.md b/dev-guide/getting-started.md deleted file mode 100644 index d751840c..00000000 --- a/dev-guide/getting-started.md +++ /dev/null @@ -1,10 +0,0 @@ -# Getting started with the experimental Amazon Bedrock Runtime client for Python - -Learn how to install, set up, and use the SDK to create an application to that uses Amazon Bedrock Runtime to programmatically access an AWS resource. - -**Important** -To use the experimental Amazon Bedrock Runtime client for Python, the user needs to have both Amazon Bedrock Runtime access and permission to use the desired model or models. See [Getting Started with Amazon Bedrock](https://docs.aws.amazon.com/https://docs.aws.amazon.com/bedrock/latest/userguide/getting-started.html) for details. - -**Topics** -+ [Installing](installing.md) -+ [Creating a simple application](simple-app.md) \ No newline at end of file diff --git a/dev-guide/index.md b/dev-guide/index.md deleted file mode 100644 index 881a0f10..00000000 --- a/dev-guide/index.md +++ /dev/null @@ -1,31 +0,0 @@ -# Experimental Amazon Bedrock Runtime client for Python Developer Guide - ------ -*****Copyright © Amazon Web Services, Inc. and/or its affiliates. All rights reserved.***** - ------ -Amazon's trademarks and trade dress may not be used in -connection with any product or service that is not Amazon's, -in any manner that is likely to cause confusion among customers, -or in any manner that disparages or discredits Amazon. All other -trademarks not owned by Amazon are the property of their respective -owners, who may or may not be affiliated with, connected to, or -sponsored by Amazon. - ------ -## Contents -+ [What is the experimental Amazon Bedrock Runtime client for Python?](what-is-the-python-sdk.md) -+ [Getting started with the experimental Amazon Bedrock Runtime client for Python](getting-started.md) - + [Installing the experimental Amazon Bedrock Runtime client for Python](installing.md) - + [Creating a simple application using the experimental Amazon Bedrock Runtime client for Python](simple-app.md) -+ [Configuring the experimental Amazon Bedrock Runtime client for Python](configuring.md) - + [Setting the AWS Region for the experimental Amazon Bedrock Runtime client for Python](region.md) - + [Using experimental Amazon Bedrock Runtime client for Python credential providers](credential-providers.md) - + [Creating service clients in the experimental Amazon Bedrock Runtime client for Python](service-clients.md) -+ [Using the experimental Amazon Bedrock Runtime client for Python](using.md) - + [Best practices for using the experimental Amazon Bedrock Runtime client for Python](best-practices.md) -+ [Security in experimental Amazon Bedrock Runtime client for Python](security.md) - + [Data protection in the experimental Amazon Bedrock Runtime client for Python](data-protection.md) - + [Compliance validation for experimental Amazon Bedrock Runtime client for Python](compliance-validation.md) - + [Resilience in the experimental Amazon Bedrock Runtime client for Python](disaster-recovery-resiliency.md) -+ [Document history for the experimental Amazon Bedrock Runtime client for Python Developer Guide](doc-history.md) \ No newline at end of file diff --git a/dev-guide/installing.md b/dev-guide/installing.md deleted file mode 100644 index 91615042..00000000 --- a/dev-guide/installing.md +++ /dev/null @@ -1,43 +0,0 @@ -# Installing the experimental Amazon Bedrock Runtime client for Python - -## Prerequisites - -To use the experimental Amazon Bedrock Runtime client for Python, you first -need a supported version of [Python](https://www.python.org/downloads/). The client requires Python 3.12 or later. - -## Set up a virtual environment - -Once you have a supported version of Python installed, you should set up your workspace by creating a virtual environment and activating it: - -``` -$ python -m venv .venv -... -$ source .venv/bin/activate -``` - -This provides an isolated space for your installation that will avoid unexpected interactions with packages installed at the system level. Skipping this step may result in unexpected dependency conflicts or failures with other tools installed on your system. - -## Installing the experimental Amazon Bedrock Runtime client for Python - -To add the SDK to your Python project, use the pip tool to install each service package into your environment. For example, to install support for the Amazon Bedrock Runtime, use the following command: - -``` -$ python -m pip install aws-sdk-bedrock-runtime -``` - -This will install into your environment the experimental Amazon Bedrock Runtime client for Python package(s) you specify, as well as their dependencies, including `[smithy-python](https://github.com/smithy-lang/smithy-python)`. - -If your project requires a specific version of the Amazon Bedrock Runtime client, you may wish to provide constraints when installing the package: - -``` -$ # Install experimental Amazon Bedrock Runtime client for Python version 0.0.1 specifically -$ python -m pip install aws-sdk-bedrock-runtime==0.0.1 - -$ # Make sure the experimental Amazon Bedrock Runtime client for Python is no older than version 0.0.2 -$ pip install aws-sdk-bedrock-runtime>=0.0.2 - -$ # Avoid versions of the experimental Amazon Bedrock Runtime client for Python newer than version 0.0.3 -$ pip install aws-sdk-bedrock-runtime<=0.0.3 -``` - -As long as the Amazon Bedrock Runtime client for Python is experimental, you may wish to pin to a specific version of the client, or to versions up to and including a specific version, in order to prevent updating to a version that isn't compatible with your application. \ No newline at end of file diff --git a/dev-guide/region.md b/dev-guide/region.md deleted file mode 100644 index 85407510..00000000 --- a/dev-guide/region.md +++ /dev/null @@ -1,42 +0,0 @@ -# Setting the AWS Region for the experimental Amazon Bedrock Runtime client for Python - -You can access AWS services that operate in a specific geographic area by using AWS Regions. This can be useful both for redundancy and to keep your data and applications running close to where you and your users access them. For more information on how Regions are used, see [AWS Region](https://docs.aws.amazon.com/sdkref/latest/guide/feature-region.html) in the *AWS SDKs and Tools Reference Guide*. - -**Important** -Most resources reside in a specific AWS Region and you must supply the correct Region for the resource when using the SDK. - -## Specifying the region inline - -The Region is specified by setting the `region` property of the `Config` object to a string giving the name of the Region. For example, to specify the region `us-east-1` when creating an Amazon Bedrock Runtime client: - -``` - service_client = BedrockRuntimeClient( - config=Config( - aws_credentials_identity_resolver=EnvironmentCredentialsResolver(), - region = "us-east-1", - ) - ) -``` - -**Note** -Not all Amazon Bedrock foundation models are available in all Regions. See [Model support by AWS Region in Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/models-regions.html) for model compatibility information. - -## Getting the region from the environment - -The experimental Amazon Bedrock Runtime client for Python does not currently support automatically retrieving the value of the `AWS_REGION` environment variable. To make your application use this variable to specify the Region in which to operate, you can add code similar to the following to your project: - -``` -import os - -... -region = os.getenv('AWS_REGION', default="us-east-1") - -service_client = BedrockRuntimeClient( - config=Config( - aws_credentials_identity_resolver=EnvironmentCredentialsResolver(), - region = region, - ) -) -``` - -This uses the value of `AWS_REGION`, falling back to `us-east-1` if the variable isn't found in the environment. diff --git a/dev-guide/security.md b/dev-guide/security.md deleted file mode 100644 index fa031cdd..00000000 --- a/dev-guide/security.md +++ /dev/null @@ -1,14 +0,0 @@ -# Security in experimental Amazon Bedrock Runtime client for Python - -Cloud security at AWS is the highest priority. As an AWS customer, you benefit from data centers and network architectures that are built to meet the requirements of the most security-sensitive organizations. - -Security is a shared responsibility between AWS and you. The [shared responsibility model](https://aws.amazon.com/compliance/shared-responsibility-model/) describes this as security *of* the cloud and security *in* the cloud: -+ **Security of the cloud** – AWS is responsible for protecting the infrastructure that runs AWS services in the AWS Cloud. AWS also provides you with services that you can use securely. Third-party auditors regularly test and verify the effectiveness of our security as part of the [AWS Compliance Programs](https://aws.amazon.com/compliance/programs/). To learn about the compliance programs that apply to the experimental Amazon Bedrock Runtime client for Python, see [AWS Services in Scope by Compliance Program](https://aws.amazon.com/compliance/services-in-scope/). -+ **Security in the cloud** – Your responsibility is determined by the AWS service that you use. You are also responsible for other factors including the sensitivity of your data, your company’s requirements, and applicable laws and regulations. - -This documentation helps you understand how to apply the shared responsibility model when using the experimental Amazon Bedrock Runtime client for Python. The following topics show you how to configure the Amazon Bedrock Runtime client to meet your security and compliance objectives. You also learn how to use other AWS services that help you to monitor and secure your Amazon Bedrock Runtime client resources. - -**Topics** -+ [Data protection in the experimental Amazon Bedrock Runtime client for Python](data-protection.md) -+ [Compliance validation for experimental Amazon Bedrock Runtime client for Python](compliance-validation.md) -+ [Resilience in the experimental Amazon Bedrock Runtime client for Python](disaster-recovery-resiliency.md) \ No newline at end of file diff --git a/dev-guide/service-clients.md b/dev-guide/service-clients.md deleted file mode 100644 index 770ab1af..00000000 --- a/dev-guide/service-clients.md +++ /dev/null @@ -1,25 +0,0 @@ -# Creating service clients in the experimental Amazon Bedrock Runtime client for Python - -To make a request to an AWS service, you first instantiate a client for that service. You can configure common settings for service clients such as timeouts, the HTTP client, and retry configuration. To create a client for Amazon Bedrock Runtime: - -``` - service_client = BedrockRuntimeClient( - config=Config( - aws_credentials_identity_resolver=EnvironmentCredentialsResolver(), - region = "us-east-1", - ) - ) -``` - -Each service client requires an AWS Region and a credential provider. The SDK uses these values to send requests to the correct Region for your resources and to sign requests with the correct credentials. You can specify these values programmatically in code or have them automatically loaded from the environment. - -The SDK has a series of places (or sources) that it checks in order to find a value for configuration settings. - -1. Any explicit setting set in the code or on a service client itself takes precedence over anything else. - -1. Environment variables - + **Note: **At this time, environment variables are only used to obtain credentials using the `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` variables. - + For details on setting environment variables, see [environment variables](https://docs.aws.amazon.com/sdkref/latest/guide/environment-variables.html) in the *AWS SDKs and Tools Reference Guide*. - -1. Any default value provided by the SDK source code itself is used last. - + Some properties, such as Region, don't have a default. You must specify them either explicitly in code or in an environment setting. If the SDK can't resolve required configuration, API requests can fail at runtime. diff --git a/dev-guide/simple-app.md b/dev-guide/simple-app.md deleted file mode 100644 index 9420a5d0..00000000 --- a/dev-guide/simple-app.md +++ /dev/null @@ -1,149 +0,0 @@ -# Creating a simple application using the experimental Amazon Bedrock Runtime client for Python - -This chapter features a short example that asks the Amazon Titan Text Express generative AI model a simple question, then outputs the response. For more details about using Amazon Bedrock Runtime in this way, see [Carry out a conversation with the Converse API operations](https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference.html) in the [Amazon Bedrock user guide](https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-bedrock.html). - -## Importing the SDK - -The first thing our program does is import the service and the types we need from it: - -``` -from aws_sdk_bedrock_runtime.client import BedrockRuntimeClient, ConverseInput -from aws_sdk_bedrock_runtime.models import Message, ContentBlockText, StopReason -from aws_sdk_bedrock_runtime.config import Config - -from smithy_aws_core.credentials_resolvers.environment import EnvironmentCredentialsResolver - -import asyncio -``` - -This imports the following from the Bedrock client: - -1. `BedrockRuntimeClient`, which is the class representing the Amazon Bedrock Runtime client. - -1. The `ConverseInput` class, which is used to specify the input values when calling the client's `converse()` function. - -The following are imported from the service's models: - -1. The `Message` class, which describes the contents of a single message sent between the application and Amazon Bedrock Runtime. - -1. The `ContentBlockText` class, which describes a block of a message's textual content. - -1. The `StopReason` type, which is an enum of values defining the reason why the Amazon Bedrock Runtime service stopped sending data back to the application. - -The `Config` type is imported. This is used to specify settings when creating a Amazon Bedrock Runtime client. - -From Smithy, the `EnvironmentCredentialsResolver` class is imported. This is a credential resolver that uses the standard AWS environment variables to specify [access keys in environment variables](https://docs.aws.amazon.com/sdkref/latest/guide/access-users.html). - -Also imported is the `asyncio` package, which is used to manage the asynchronous I/O used by the application. - -## Creating the Amazon Bedrock Runtime client - -To create the Amazon Bedrock Runtime client, create a `BedrockRuntimeClient` instance using a `Config` object providing the AWS Region to use. In this example, a credentials identity resolver is provided that uses the standard AWS [access keys in environment variables](https://docs.aws.amazon.com/sdkref/latest/guide/access-users.html) are used to specify credentials. - -``` -def get_service_client(): - service_client = BedrockRuntimeClient( - config=Config( - aws_credentials_identity_resolver=EnvironmentCredentialsResolver(), - region = "us-east-1", - ) - ) - return service_client -``` - -## Creating the request messages - -Then construct an array of `Message` objects which describe the query you wish Amazon Bedrock Runtime to process. - -``` -def create_messages(): - message_1 = Message( - role="user", - content=[ - ContentBlockText( - value="Create a list of 3 of the best songs from the 1980s." - ) - ] - ) - return [message_1] -``` - -## Sending the messages to Amazon Bedrock Runtime - -Then send the messages to the Amazon Bedrock Runtime service by calling the client's `converse()` function, specifying in its `ConverseInput` which model to use when processing the request. - -``` -async def send_messages(service_client, messages): - try: - response = await service_client.converse( - ConverseInput( - model_id='amazon.titan-text-express-v1', messages=messages - ) - ) - except: - print("An error occurred while conversing!") - return - - # Get the `ConverseOutput` object from the `ConverseOperationOutput`. This - # is a `ConverseOutputMessage` unless an unexpected response arrives. - output = response.output - - # Check the reason why the operation ended. - stop_reason = response.stop_reason - - match stop_reason: - case StopReason.GUARDRAIL_INTERVENED: - print("A guardrail intervened in the response.") - case StopReason.CONTENT_FILTERED: - print("The content was filtered.") - case StopReason.MAX_TOKENS: - print("You ran out of tokens.") - case _: - pass - - return output -``` - -Once the response is received, this code also checks the reason why the response stops where it does, and outputs an appropriate message for some specific cases of interest, such as running out of tokens. The response's `output` is returned; this is of type `ConverseOutput`, which resolves to `ConverseOutputMessage` if nothing went wrong. - -## Outputting the results - -Once the response has been received, the reply can be output to the user. - -``` -def output_reply(output): - # Get the `Message` from the `ConverseOutputMessage` object. - output_msg = output.value - - # Get the content of the message from its `content` property. This is - # an array of `ContentBlock` objects, each representing a piece of the - # response. - msg_contents = output_msg.content - - # Output the returned text by printing the value of each - # `ContentBlockText` object found in the `msg_contents` array. - for msg_block in msg_contents: - if isinstance(msg_block, ContentBlockText): - print(msg_block.value) - else: - print("Unexpected type of response.") -``` - -In this example, all of the returned blocks of type `ContentBlockText` are output, in order to display the text portion of the response. Any other type of block results in the message "Unexpected type of response." - -## Wrapping up the application - -The application body is a short function that just calls each of the above in order. - -``` -async def app_run(): - service_client = get_service_client() - messages = create_messages() - output = await send_messages(service_client, messages) - - if output: - output_reply(output) - -if __name__ == "__main__": - asyncio.run(app_run()) -``` diff --git a/dev-guide/using.md b/dev-guide/using.md deleted file mode 100644 index 66101c05..00000000 --- a/dev-guide/using.md +++ /dev/null @@ -1,6 +0,0 @@ -# Using the experimental Amazon Bedrock Runtime client for Python - -Learn common and recommended ways of programming with the experimental Amazon Bedrock Runtime client for Python in your applications. - -**Topics** -+ [Best practices](best-practices.md) \ No newline at end of file diff --git a/dev-guide/what-is-the-python-sdk.md b/dev-guide/what-is-the-python-sdk.md deleted file mode 100644 index 8ce8c4af..00000000 --- a/dev-guide/what-is-the-python-sdk.md +++ /dev/null @@ -1,27 +0,0 @@ -# What is the experimental Amazon Bedrock Runtime client for Python? - -Welcome to the experimental Amazon Bedrock Runtime client for Python, a new [Smithy](https://smithy.io/)-based SDK that lets Python developers create applications that use Amazon Bedrock Runtime. - -**Important** -The experimental Amazon Bedrock Runtime client for Python is an experimental async Python SDK that allows developers to take advantage of Amazon Bedrock Runtime. It is currently in early stages of development. **There are likely to be breaking changes** during this phase of the SDK's development. - -**Note** -Currently, the only service supported by this package is Amazon Bedrock Runtime. To access other services, use the current AWS SDK for Python, [Boto3](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/index.html). -You can use Boto3 and the experimental Amazon Bedrock Runtime client for Python together to create comprehensive Python applications that access AWS services. - -**Topics** -+ [Get started with the SDK](#first-time-user) -+ [Additional resources](#additional-resources) - -## Get started with the SDK - -If you are a first-time user of the experimental Amazon Bedrock Runtime client for Python, we recommend that you begin by reading the following sections: -+ To get started using the SDK, follow the tutorial in [Getting started with the experimental Amazon Bedrock Runtime client for Python](getting-started.md). -+ To set up your development environment, see [Installing the experimental Amazon Bedrock Runtime client for Python](installing.md). -+ To create and configure service clients for making requests to AWS services, see [Configuring the experimental Amazon Bedrock Runtime client for Python](configuring.md). For information on the features offered by the SDK and how to use them, see [Using the experimental Amazon Bedrock Runtime client for Python](using.md). - -## Additional resources - -In addition to this guide, the following are valuable online resources for experimental Amazon Bedrock Runtime client for Python developers. -+ The experimental Amazon Bedrock Runtime client for Python API Reference (link forthcoming) -+ [Amazon Bedrock Runtime API Reference](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_Operations_Amazon_Bedrock_Runtime.html) \ No newline at end of file