3131from ....types .traces import AttributeValue
3232from ..event_loop .bidirectional_event_loop import start_bidirectional_connection , stop_bidirectional_connection
3333from ..models .bidirectional_model import BidirectionalModel
34- from ..types .bidirectional_streaming import AudioInputEvent , BidirectionalStreamEvent
34+ from ..types .bidirectional_streaming import AudioInputEvent , BidirectionalStreamEvent , ImageInputEvent
3535
3636logger = logging .getLogger (__name__ )
3737
@@ -359,18 +359,16 @@ async def start(self) -> None:
359359
360360 logger .debug ("Conversation start - initializing session" )
361361 self ._session = await start_bidirectional_connection (self )
362- logger .debug ("Conversation ready" )
363-
364- async def send (self , input_data : str | AudioInputEvent ) -> None :
365- """Send input to the model (text or audio).
366-
367- Unified method for sending both text and audio input to the model during
368- an active conversation session. User input is automatically added to
369- conversation history for complete message tracking.
370-
362+
363+ async def send (self , input_data : str | AudioInputEvent | ImageInputEvent ) -> None :
364+ """Send input to the model (text, audio, or image).
365+
366+ Unified method for sending text, audio, and image input to the model during
367+ an active conversation session.
368+
371369 Args:
372- input_data: Either a string for text input or AudioInputEvent for audio input .
373-
370+ input_data: String for text, AudioInputEvent for audio, or ImageInputEvent for images .
371+
374372 Raises:
375373 ValueError: If no active session or invalid input type.
376374 """
@@ -385,10 +383,14 @@ async def send(self, input_data: str | AudioInputEvent) -> None:
385383 elif isinstance (input_data , dict ) and "audioData" in input_data :
386384 # Handle audio input
387385 await self ._session .model_session .send_audio_content (input_data )
386+ elif isinstance (input_data , dict ) and "imageData" in input_data :
387+ # Handle image input (ImageInputEvent)
388+ await self ._session .model_session .send_image_content (input_data )
388389 else :
389390 raise ValueError (
390- "Input must be either a string (text) or AudioInputEvent "
391- "(dict with audioData, format, sampleRate, channels)"
391+ "Input must be either a string (text), AudioInputEvent "
392+ "(dict with audioData, format, sampleRate, channels), or ImageInputEvent "
393+ "(dict with imageData, mimeType, encoding)"
392394 )
393395
394396 async def receive (self ) -> AsyncIterable [BidirectionalStreamEvent ]:
0 commit comments