Add Gemini Model Provider #4
Open
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.
Add Gemini Live API Support for Bidirectional Streaming
Description
This PR adds support for Google's Gemini Live API as a bidirectional streaming model provider, enabling real-time audio conversations with native audio input/output, image/video input, and automatic transcription.
Key Features
Gemini Live Model Provider (
gemini_live.py)google-genaiSDK for robust WebSocket communicationEnhanced Bidirectional Streaming
ImageInputEventtype for sending images/video framesTranscriptEventtype for audio transcriptions (separate from text output)BidirectionalAgent.send()to accept text, audio, and image inputsBidirectionalModelSessioninterface withsend_image_content()Test Suite Enhancements
Implementation Details
The implementation follows the same architectural patterns as Nova Sonic:
Configuration Example
Related Issues
Documentation PR
Type of Change
New feature
Testing
How have you tested the change?
hatch fmtfor code formattingTest Environment
google-genai,pyaudio,opencv-python,pillowGOOGLE_AI_API_KEYenvironment variableFiles Changed
src/strands/experimental/bidirectional_streaming/models/gemini_live.py(501 lines)src/strands/experimental/bidirectional_streaming/agent/agent.py- Added image input supportsrc/strands/experimental/bidirectional_streaming/models/bidirectional_model.py- Added abstractsend_image_content()methodsrc/strands/experimental/bidirectional_streaming/models/novasonic.py- Added stub for image input (not supported)src/strands/experimental/bidirectional_streaming/types/bidirectional_streaming.py- AddedImageInputEventandTranscriptEventtypessrc/strands/experimental/bidirectional_streaming/tests/test_bidirectional_streaming.py- Enhanced test with Gemini Live and camera supportVerify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.