Skip to main content

Client library for the anthropic API with the AWS Bedrock endpoint.

Project description

Anthropic Bedrock Python SDK

bedrock-anthropic is a python library for interacting with Anthropic's models on AWS Bedrock. It makes it really easy to use Anthropic's models in your application.

Created by: Mustafa Aljadery & Siddharth Sharma.

Complete Docs

Installation

Install bedrock-anthropic using pip:

pip install bedrock-anthropic

Authentication

This is an example using access & secret keys. For more authentication examples, refer to the docs.

import os
from bedrock_anthropic import AnthropicBedrock

anthropic = AnthropicBedrock(
    access_key=os.getenv("AWS_ACCESS_KEY"),
    secret_key=os.getenv("AWS_SECRET_KEY")
)

Example

An example of using the Completion endpoint in this SDK.

import os
from bedrock_anthropic import AnthropicBedrock

anthropic = AnthropicBedrock(
    access_key=os.getenv("AWS_ACCESS_KEY"),
    secret_key=os.getenv("AWS_SECRET_KEY")
)

completion = anthropic.Completion.create(
    model="anthropic.claude-v2",
    prompt="Why is the sky blue?",
    max_tokens_to_sample=300
)

print(completion["completion"])

Response

There are a few main reasons why the sky appears blue:

- Rayleigh scattering - Light from the sun is scattered by nitrogen and oxygen molecules in the atmosphere. Shorter wavelengths like blue and violet are scattered more easily than longer wavelengths, making the sky appear blue.

- The composition of the atmosphere - Nitrogen and oxygen account for most of the atmosphere. These gases are efficient at scattering blue light.

- The angle of the sun - The sky appears blue during the day but red/orange during sunrise and sunset because of the angle sunlight has to pass through the atmosphere. More blue light is scattered away from the line of sight when the sun is higher overhead.

- Water and dust - Additional scattering by water and dust particles in the atmosphere can also contribute to the blue color.

So in summary, the main factors are Rayleigh scattering by air molecules that preferentially scatters blue light, the gases that make up our atmosphere, and the angle/amount of atmosphere sunlight has to pass through. This gives the sky its familiar blue hue during the day.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bedrock_anthropic-0.0.5.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

bedrock_anthropic-0.0.5-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file bedrock_anthropic-0.0.5.tar.gz.

File metadata

  • Download URL: bedrock_anthropic-0.0.5.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for bedrock_anthropic-0.0.5.tar.gz
Algorithm Hash digest
SHA256 3c629bc905a2721819450e00ccb6ace70a5929ffa598e6d8a08719dcdfceb363
MD5 a7ec88c33a8fb110b59348b10d970f3d
BLAKE2b-256 d0d1315492513949cd8133b2fa403e19711a786d84e32ba6115853426690ed8c

See more details on using hashes here.

File details

Details for the file bedrock_anthropic-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for bedrock_anthropic-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ba7ad654cc43c9d87f2344ec16d2dcc95364e583e26b632e7ac719cf671c98ce
MD5 03cb536a54a51307810f7fc3d6b5e28e
BLAKE2b-256 f7acdd5af0810dc954308614ec495b9e2c6414a7a7cfe7c6f5844e378bf10904

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page