Skip to main content

Bedrock Converse API Data Types

Project description

Amazon Bedrock Converse API Data Types

PyPI version release PyPI - Python Version Pydantic v2

This project is a Pydantic implementation of Amazon Bedrock Runtime Converse API Data Types.

Example Usage

from bedrock_types import ConverseResponse

...

response = client.converse(
    modelId=model_id,
    messages=messages,
    system=system_prompts,
    inferenceConfig=inference_config,
    additionalModelRequestFields=additional_model_fields,
)

parsed = ConverseResponse.model_validate(response)
print(parsed.model_dump_json(indent=4, exclude_unset=True))
print(parsed.ResponseMetadata)

Output

ResponseMetadata={'RequestId': '427c73bb-df2d-4c1a-8744-db1b5b3c4897', 'HTTPStatusCode': 200, 'HTTPHeaders': {'date': 'Thu, 13 Jun 2024 09:11:25 GMT', 'content-type': 'application/json', 'content-length': '247', 'connection': 'keep-alive', 'x-amzn-requestid': '427c73bb-df2d-4c1a-8744-db1b5b3c4897'}, 'RetryAttempts': 0} additionalModelResponseFields=None metrics=ConverseMetrics(latencyMs=740) output=ConverseOutput(message=Message(content=[ContentBlock(image=None, text="Why don't scientists trust atoms? Because they make up everything!", toolResult=None, toolUse=None)], role='assistant')) stopReason='end_turn' usage=TokenUsage(inputTokens=22, outputTokens=16, totalTokens=38)
{
    "ResponseMetadata": {
        "RequestId": "427c73bb-df2d-4c1a-8744-db1b5b3c4897",
        "HTTPStatusCode": 200,
        "HTTPHeaders": {
            "date": "Thu, 13 Jun 2024 09:11:25 GMT",
            "content-type": "application/json",
            "content-length": "247",
            "connection": "keep-alive",
            "x-amzn-requestid": "427c73bb-df2d-4c1a-8744-db1b5b3c4897"
        },
        "RetryAttempts": 0
    },
    "metrics": {
        "latencyMs": 740
    },
    "output": {
        "message": {
            "content": [
                {
                    "text": "Why don't scientists trust atoms? Because they make up everything!"
                }
            ],
            "role": "assistant"
        }
    },
    "stopReason": "end_turn",
    "usage": {
        "inputTokens": 22,
        "outputTokens": 16,
        "totalTokens": 38
    }
}
{'RequestId': '427c73bb-df2d-4c1a-8744-db1b5b3c4897', 'HTTPStatusCode': 200, 'HTTPHeaders': {'date': 'Thu, 13 Jun 2024 09:11:25 GMT', 'content-type': 'application/json', 'content-length': '247', 'connection': 'keep-alive', 'x-amzn-requestid': '427c73bb-df2d-4c1a-8744-db1b5b3c4897'}, 'RetryAttempts': 0}

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_types-0.1.3.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

bedrock_types-0.1.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file bedrock_types-0.1.3.tar.gz.

File metadata

  • Download URL: bedrock_types-0.1.3.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for bedrock_types-0.1.3.tar.gz
Algorithm Hash digest
SHA256 189bbca5ade725de0af8462a445daf8702c4f51bef954f04ce6bcde0c60fdd5f
MD5 bc8bc3ae82570f388c0be4be9454bd51
BLAKE2b-256 e895062b944a77283e50e226ac05e5dc59367070066daf5769a0b9365bbc3e7d

See more details on using hashes here.

File details

Details for the file bedrock_types-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for bedrock_types-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 405e82dea3786088a32ab357e7b94e5a52b32add894626137d308fc96465ac9a
MD5 2a247dbbae9be6b1aa86cbb4071b5320
BLAKE2b-256 aa2bb23f56302b8083f09491e925cc77b45b5bbf821593550bfca944632b596a

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