Skip to content

Commit ef3d659

Browse files
authored
Merge pull request strands-agents#43 from mehtarac/bidio_interface
1 parent 55c5c94 commit ef3d659

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

src/strands/experimental/bidi/agent/agent.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,20 +422,24 @@ async def run_outputs():
422422
await output(event)
423423

424424
for input_ in inputs:
425-
await input_.start()
425+
if hasattr(input_, "start"):
426+
await input_.start()
426427

427428
for output in outputs:
428-
await output.start()
429+
if hasattr(output, "start"):
430+
await output.start()
429431

430432
try:
431433
await asyncio.gather(run_inputs(), run_outputs(), return_exceptions=True)
432434

433435
finally:
434436
for input_ in inputs:
435-
await input_.stop()
437+
if hasattr(input_, "stop"):
438+
await input_.stop()
436439

437440
for output in outputs:
438-
await output.stop()
441+
if hasattr(output, "stop"):
442+
await output.stop()
439443

440444
def _validate_active_connection(self) -> None:
441445
"""Validate that an active connection exists.

src/strands/experimental/bidi/io/audio.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
class _BidiAudioInput(BidiInput):
20-
"Handle audio input from bidi agent."
20+
"""Handle audio input from bidi agent."""
2121
def __init__(self, audio: "BidiAudioIO") -> None:
2222
"""Store reference to pyaudio instance."""
2323
self.audio = audio
@@ -43,7 +43,7 @@ async def __call__(self) -> BidiAudioInputEvent:
4343

4444

4545
class _BidiAudioOutput(BidiOutput):
46-
"Handle audio output from bidi agent."
46+
"""Handle audio output from bidi agent."""
4747
def __init__(self, audio: "BidiAudioIO") -> None:
4848
"""Store reference to pyaudio instance."""
4949
self.audio = audio
@@ -115,11 +115,11 @@ def __init__(
115115
self.interrupted = False
116116

117117
def input(self) -> _BidiAudioInput:
118-
"Return audio processing BidiInput"
118+
"""Return audio processing BidiInput"""
119119
return _BidiAudioInput(self)
120120

121121
def output(self) -> _BidiAudioOutput:
122-
"Return audio processing BidiOutput"
122+
"""Return audio processing BidiOutput"""
123123
return _BidiAudioOutput(self)
124124

125125
def _start(self) -> None:

src/strands/experimental/bidi/io/text.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
class _BidiTextOutput(BidiOutput):
12-
"Handle text output from bidi agent."
12+
"""Handle text output from bidi agent."""
1313
async def __call__(self, event: BidiOutputEvent) -> None:
1414
"""Print text events to stdout."""
1515

@@ -25,7 +25,7 @@ async def __call__(self, event: BidiOutputEvent) -> None:
2525

2626

2727
class BidiTextIO:
28-
"Handle text input and output from bidi agent."
28+
"""Handle text input and output from bidi agent."""
2929
def output(self) -> _BidiTextOutput:
3030
"Return text processing BidiOutput"
3131
return _BidiTextOutput()

0 commit comments

Comments
 (0)