Skip to content

Commit

Permalink
fixed reengage timing
Browse files Browse the repository at this point in the history
  • Loading branch information
rde8026 committed Feb 29, 2024
1 parent 73f3d1a commit d144f52
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions vocode/streaming/streaming_conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ async def process(self, item: InterruptibleAgentResponseEvent[AgentResponse]):
is_interruptible=item.is_interruptible,
agent_response_tracker=item.agent_response_tracker,
)
self.conversation.mark_last_agent_response()
except asyncio.CancelledError:
pass

Expand Down Expand Up @@ -385,7 +386,6 @@ async def process(
await self.conversation.terminate()
except asyncio.TimeoutError:
pass
self.conversation.mark_last_agent_response()
except asyncio.CancelledError:
pass

Expand Down Expand Up @@ -712,6 +712,7 @@ async def send_speech_to_output(
"Sent chunk {} with size {}".format(chunk_idx, len(chunk_result.chunk))
)
self.mark_last_action_timestamp()
self.mark_last_agent_response()
chunk_idx += 1
seconds_spoken += seconds_per_chunk
if transcript_message:
Expand Down Expand Up @@ -790,7 +791,7 @@ async def check_if_human_should_be_prompted(self):
if self.last_agent_response and self.last_final_transcript_from_human:
last_human_touchpoint = time.time() - self.last_final_transcript_from_human
last_agent_touchpoint = time.time() - self.last_agent_response
if last_human_touchpoint >= reengage_timeout and last_agent_touchpoint >= reengage_timeout:
if (last_human_touchpoint >= reengage_timeout) and (last_agent_touchpoint >= reengage_timeout):
reengage_statement = random.choice(reengage_options)
self.logger.debug(f"Prompting user with {reengage_statement}: no interaction has happened in {reengage_timeout} seconds")
self.chunk_size = (
Expand All @@ -812,7 +813,7 @@ async def check_if_human_should_be_prompted(self):
agent_response_tracker=asyncio.Event(),
)
self.mark_last_agent_response()
await asyncio.sleep(1)
await asyncio.sleep(2.5)
else:
await asyncio.sleep(1)
self.logger.debug("stopped check if human should be prompted")
Expand Down

0 comments on commit d144f52

Please sign in to comment.