Skip to content

Commit 3a9f944

Browse files
author
Murat Kaan Meral
committed
refactor: rename to bidi input and output events
1 parent 8918757 commit 3a9f944

8 files changed

Lines changed: 30 additions & 30 deletions

File tree

src/strands/experimental/bidirectional_streaming/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
BidiConnectionStartEvent,
2323
BidiErrorEvent,
2424
BidiImageInputEvent,
25-
InputEvent,
25+
BidiInputEvent,
2626
BidiInterruptionEvent,
2727
ModalityUsage,
2828
BidiUsageEvent,
29-
OutputEvent,
29+
BidiOutputEvent,
3030
BidiResponseCompleteEvent,
3131
BidiResponseStartEvent,
3232
BidiTextInputEvent,
@@ -54,7 +54,7 @@
5454
"BidiTextInputEvent",
5555
"BidiAudioInputEvent",
5656
"BidiImageInputEvent",
57-
"InputEvent",
57+
"BidiInputEvent",
5858

5959
# Output Event types
6060
"BidiConnectionStartEvent",
@@ -67,7 +67,7 @@
6767
"BidiUsageEvent",
6868
"ModalityUsage",
6969
"BidiErrorEvent",
70-
"OutputEvent",
70+
"BidiOutputEvent",
7171

7272
# Tool Event types (reused from standard agent)
7373
"ToolUseStreamEvent",

src/strands/experimental/bidirectional_streaming/agent/agent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
)
3535
from ..models.bidirectional_model import BidiModel
3636
from ..models.novasonic import BidiNovaSonicModel
37-
from ..types.events import BidiAudioInputEvent, BidiImageInputEvent, BidiTextInputEvent, InputEvent, OutputEvent
37+
from ..types.events import BidiAudioInputEvent, BidiImageInputEvent, BidiTextInputEvent, BidiInputEvent, BidiOutputEvent
3838
from ..types import BidiIO
3939
from ....experimental.tools import ToolProvider
4040

@@ -325,10 +325,10 @@ async def send(self, input_data: BidirectionalInput) -> None:
325325

326326
# If we get here, input type is invalid
327327
raise ValueError(
328-
f"Input must be a string, InputEvent (BidiTextInputEvent/BidiAudioInputEvent/BidiImageInputEvent), or event dict with 'type' field, got: {type(input_data)}"
328+
f"Input must be a string, BidiInputEvent (BidiTextInputEvent/BidiAudioInputEvent/BidiImageInputEvent), or event dict with 'type' field, got: {type(input_data)}"
329329
)
330330

331-
async def receive(self) -> AsyncIterable[OutputEvent]:
331+
async def receive(self) -> AsyncIterable[BidiOutputEvent]:
332332
"""Receive events from the model including audio, text, and tool calls.
333333
334334
Yields model output events processed by background tasks including audio output,

src/strands/experimental/bidirectional_streaming/models/bidirectional_model.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
from ..types.events import (
2222
BidiAudioInputEvent,
2323
BidiImageInputEvent,
24-
InputEvent,
25-
OutputEvent,
24+
BidiInputEvent,
25+
BidiOutputEvent,
2626
BidiTextInputEvent,
2727
)
2828

@@ -67,7 +67,7 @@ async def stop(self) -> None:
6767
"""
6868
...
6969

70-
async def receive(self) -> AsyncIterable[OutputEvent]:
70+
async def receive(self) -> AsyncIterable[BidiOutputEvent]:
7171
"""Receive streaming events from the model.
7272
7373
Continuously yields events from the model as they arrive over the connection.
@@ -77,14 +77,14 @@ async def receive(self) -> AsyncIterable[OutputEvent]:
7777
The stream continues until the connection is closed or an error occurs.
7878
7979
Yields:
80-
OutputEvent: Standardized event objects containing audio output,
80+
BidiOutputEvent: Standardized event objects containing audio output,
8181
transcripts, tool calls, or control signals.
8282
"""
8383
...
8484

8585
async def send(
8686
self,
87-
content: InputEvent | ToolResultEvent,
87+
content: BidiInputEvent | ToolResultEvent,
8888
) -> None:
8989
"""Send content to the model over the active connection.
9090

src/strands/experimental/bidirectional_streaming/models/gemini_live.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
BidiConnectionStartEvent,
3232
BidiErrorEvent,
3333
BidiImageInputEvent,
34-
InputEvent,
34+
BidiInputEvent,
3535
BidiInterruptionEvent,
3636
BidiUsageEvent,
3737
BidiTextInputEvent,
@@ -334,7 +334,7 @@ def _convert_gemini_live_event(self, message: LiveServerMessage) -> Optional[Dic
334334

335335
async def send(
336336
self,
337-
content: InputEvent | ToolResultEvent,
337+
content: BidiInputEvent | ToolResultEvent,
338338
) -> None:
339339
"""Unified send method for all content types. Sends the given inputs to Google Live API
340340

src/strands/experimental/bidirectional_streaming/models/novasonic.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
BidiConnectionStartEvent,
4141
BidiErrorEvent,
4242
BidiImageInputEvent,
43-
InputEvent,
43+
BidiInputEvent,
4444
BidiInterruptionEvent,
4545
BidiUsageEvent,
46-
OutputEvent,
46+
BidiOutputEvent,
4747
BidiTextInputEvent,
4848
BidiTranscriptStreamEvent,
4949
BidiResponseCompleteEvent,
@@ -308,7 +308,7 @@ async def receive(self) -> AsyncIterable[dict[str, any]]:
308308

309309
async def send(
310310
self,
311-
content: InputEvent | ToolResultEvent,
311+
content: BidiInputEvent | ToolResultEvent,
312312
) -> None:
313313
"""Unified send method for all content types. Sends the given content to Nova Sonic.
314314
@@ -513,7 +513,7 @@ async def stop(self) -> None:
513513
finally:
514514
logger.debug("Nova connection closed")
515515

516-
def _convert_nova_event(self, nova_event: dict[str, any]) -> OutputEvent | None:
516+
def _convert_nova_event(self, nova_event: dict[str, any]) -> BidiOutputEvent | None:
517517
"""Convert Nova Sonic events to TypedEvent format."""
518518
# Handle completion start - track completionId
519519
if "completionStart" in nova_event:

src/strands/experimental/bidirectional_streaming/models/openai.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
BidiConnectionStartEvent,
2626
BidiErrorEvent,
2727
BidiImageInputEvent,
28-
InputEvent,
28+
BidiInputEvent,
2929
BidiInterruptionEvent,
3030
BidiUsageEvent,
31-
OutputEvent,
31+
BidiOutputEvent,
3232
BidiTextInputEvent,
3333
BidiTranscriptStreamEvent,
3434
BidiResponseCompleteEvent,
@@ -291,7 +291,7 @@ async def _process_responses(self) -> None:
291291
self._active = False
292292
logger.debug("OpenAI Realtime response processor stopped")
293293

294-
async def receive(self) -> AsyncIterable[OutputEvent]:
294+
async def receive(self) -> AsyncIterable[BidiOutputEvent]:
295295
"""Receive OpenAI events and convert to Strands TypedEvent format."""
296296
# Emit connection start event
297297
yield BidiConnectionStartEvent(
@@ -315,7 +315,7 @@ async def receive(self) -> AsyncIterable[OutputEvent]:
315315
# Emit connection close event
316316
yield BidiConnectionCloseEvent(connection_id=self.connection_id, reason="complete")
317317

318-
def _convert_openai_event(self, openai_event: dict[str, any]) -> list[OutputEvent] | None:
318+
def _convert_openai_event(self, openai_event: dict[str, any]) -> list[BidiOutputEvent] | None:
319319
"""Convert OpenAI events to Strands TypedEvent format."""
320320
event_type = openai_event.get("type")
321321

@@ -526,7 +526,7 @@ def _convert_openai_event(self, openai_event: dict[str, any]) -> list[OutputEven
526526

527527
async def send(
528528
self,
529-
content: InputEvent | ToolResultEvent,
529+
content: BidiInputEvent | ToolResultEvent,
530530
) -> None:
531531
"""Unified send method for all content types. Sends the given content to OpenAI.
532532

src/strands/experimental/bidirectional_streaming/types/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
BidiConnectionStartEvent,
1515
BidiErrorEvent,
1616
BidiImageInputEvent,
17-
InputEvent,
17+
BidiInputEvent,
1818
BidiInterruptionEvent,
1919
ModalityUsage,
2020
BidiUsageEvent,
21-
OutputEvent,
21+
BidiOutputEvent,
2222
BidiResponseCompleteEvent,
2323
BidiResponseStartEvent,
2424
BidiTextInputEvent,
@@ -31,7 +31,7 @@
3131
"BidiTextInputEvent",
3232
"BidiAudioInputEvent",
3333
"BidiImageInputEvent",
34-
"InputEvent",
34+
"BidiInputEvent",
3535
# Output Events
3636
"BidiConnectionStartEvent",
3737
"BidiConnectionCloseEvent",
@@ -43,7 +43,7 @@
4343
"BidiUsageEvent",
4444
"ModalityUsage",
4545
"BidiErrorEvent",
46-
"OutputEvent",
46+
"BidiOutputEvent",
4747
# Constants
4848
"SUPPORTED_AUDIO_FORMATS",
4949
"SUPPORTED_SAMPLE_RATES",

src/strands/experimental/bidirectional_streaming/types/events.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,11 +504,11 @@ def details(self) -> Optional[Dict[str, Any]]:
504504
# ============================================================================
505505

506506
# Note: ToolResultEvent is imported from strands.types._events and used alongside
507-
# InputEvent in send() methods for sending tool results back to the model.
507+
# BidiInputEvent in send() methods for sending tool results back to the model.
508508

509-
InputEvent = BidiTextInputEvent | BidiAudioInputEvent | BidiImageInputEvent
509+
BidiInputEvent = BidiTextInputEvent | BidiAudioInputEvent | BidiImageInputEvent
510510

511-
OutputEvent = (
511+
BidiOutputEvent = (
512512
BidiConnectionStartEvent
513513
| BidiResponseStartEvent
514514
| BidiAudioStreamEvent

0 commit comments

Comments
 (0)