Skip to content

Commit

Permalink
Merge branch 'main' into hayden/epd-459-add-fix-assistant-messages-sh…
Browse files Browse the repository at this point in the history
…ouldnt-be-split-up-across-the
  • Loading branch information
HHousen committed Aug 4, 2023
2 parents 88abb8c + 8895679 commit d81ef97
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
8 changes: 0 additions & 8 deletions vocode/streaming/agent/base_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,6 @@ def attach_conversation_state_manager(
):
self.conversation_state_manager = conversation_state_manager

def start(self):
super().start()
if self.agent_config.initial_message is not None:
self.produce_interruptible_agent_response_event_nonblocking(
AgentResponseMessage(message=self.agent_config.initial_message, message_id="initial_message"),
is_interruptible=False,
)

def set_interruptible_event_factory(self, factory: InterruptibleEventFactory):
self.interruptible_event_factory = factory

Expand Down
19 changes: 19 additions & 0 deletions vocode/streaming/streaming_conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,11 @@ async def start(self, mark_ready: Optional[Callable[[], Awaitable[None]]] = None
FillerAudioConfig, self.agent.get_agent_config().send_filler_audio
)
await self.synthesizer.set_filler_audios(self.filler_audio_config)

self.agent.start()
initial_message = self.agent.get_agent_config().initial_message
if initial_message:
asyncio.create_task(self.send_initial_message(initial_message))
self.agent.attach_transcript(self.transcript)
if mark_ready:
await mark_ready()
Expand All @@ -489,6 +493,21 @@ async def start(self, mark_ready: Optional[Callable[[], Awaitable[None]]] = None
if len(self.events_manager.subscriptions) > 0:
self.events_task = asyncio.create_task(self.events_manager.start())

async def send_initial_message(self, initial_message: BaseMessage):
# TODO: configure if initial message is interruptible
self.transcriber.mute()
initial_message_tracker = asyncio.Event()
agent_response_event = (
self.interruptible_event_factory.create_interruptible_agent_response_event(
AgentResponseMessage(message=initial_message),
is_interruptible=False,
agent_response_tracker=initial_message_tracker,
)
)
self.agent_responses_worker.consume_nonblocking(agent_response_event)
await initial_message_tracker.wait()
self.transcriber.unmute()

async def check_for_idle(self):
"""Terminates the conversation after 15 seconds if no activity is detected"""
while self.is_active():
Expand Down

0 comments on commit d81ef97

Please sign in to comment.