-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
See https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-call.html, under Request > messages > video:
You can also specify an Amazon S3 URI instead of passing the bytes directly in the request body. The following shows a sample Message object with a content array containing the source passed through an Amazon S3 URI.
{ "role": "user", "content": [ { "video": { "format": "mp4", "source": { "s3Location": { "uri": "s3://amzn-s3-demo-bucket/myVideo", "bucketOwner": "111122223333" } } } } ] }The assumed role must have the
s3:GetObjectpermission to the Amazon S3 URI. ThebucketOwnerfield is optional but must be specified if the account making the request does not own the bucket the Amazon S3 URI is found in. For more information, see Configure access to Amazon S3 buckets.
We’d just need to edit this:
pydantic-ai/pydantic_ai_slim/pydantic_ai/models/bedrock.py
Lines 645 to 652 in 4ec0b32
| elif isinstance(item, ImageUrl | DocumentUrl | VideoUrl): | |
| downloaded_item = await download_item(item, data_format='bytes', type_format='extension') | |
| format = downloaded_item['data_type'] | |
| if item.kind == 'image-url': | |
| format = item.media_type.split('/')[1] | |
| assert format in ('jpeg', 'png', 'gif', 'webp'), f'Unsupported image format: {format}' | |
| image: ImageBlockTypeDef = {'format': format, 'source': {'bytes': downloaded_item['data']}} | |
| content.append({'image': image}) |
We already support gs:// URLs with GoogleModel as well, as documented on https://ai.pydantic.dev/input.
Also related to: