feat(types): add native audio content block support#1515
Open
strands-agent wants to merge 1 commit intostrands-agents:mainfrom
Open
feat(types): add native audio content block support#1515strands-agent wants to merge 1 commit intostrands-agents:mainfrom
strands-agent wants to merge 1 commit intostrands-agents:mainfrom
Conversation
Adds AudioContent TypedDict to support audio input in messages, following the established pattern for image and video content. Changes: - Add AudioFormat Literal type with common audio formats (mp3, wav, flac, ogg, aac, webm) - Add AudioSource TypedDict for audio binary content - Add AudioContent TypedDict with format and source fields - Add 'audio' field to ContentBlock TypedDict - Add audio handling in BedrockModel._format_request_message_content() - Add unit test for audio content block filtering This enables type-safe audio input for model providers that support multimodal audio content, such as Bedrock (Nova Sonic) and LlamaCpp (Qwen2.5-Omni). Closes strands-agents#866
292e851 to
07b34c5
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add native audio content block support to the SDK's type system, following the established pattern for video, image, and document content.
Changes
Types (
src/strands/types/media.py):AudioFormatliteral type (mp3,wav,flac,ogg,webm)AudioSourceTypedDict withbytesattributeAudioContentTypedDict withformatandsourceattributesContentBlock (
src/strands/types/content.py):audio: AudioContentfield to theContentBlockTypedDictBedrock Provider (
src/strands/models/bedrock.py):_format_request_message_content()following the video patternLlamaCpp Provider (
src/strands/models/llamacpp.py):AudioContenttypes instead ofcast(Dict[str, Any], content)Tests (
tests/strands/models/test_bedrock.py):test_format_request_filters_audio_content_blockstestBenefits
cast(Dict[str, Any], content)workaroundsUsage Example
Related Issues
Closes #866
Documentation PR
No documentation changes required - this adds types that follow existing patterns.
Type of Change
New feature
Testing
hatch run prepare(formatter + linter + mypy + tests)test_format_request_filters_audio_content_blocksChecklist