Skip to content

Commit

Permalink
Move vector db terminate code to streaming_conversation (#324)
Browse files Browse the repository at this point in the history
* Move terminate code to streaming_conversation

* Add await

* Add comment
  • Loading branch information
HHousen authored Aug 1, 2023
1 parent c61aea2 commit 9ebbc82
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 0 additions & 9 deletions vocode/streaming/agent/base_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,15 +424,6 @@ async def get_tracer_name_start(self) -> str:
self.tracer_name_start: str = tracer_name_start
return tracer_name_start

def terminate(self):
if (
hasattr(self.agent_config, "vector_db_config")
and self.agent_config.vector_db_config
):
self.logger.debug("Terminating vector db")
self.vector_db.tear_down()
return super().terminate()

async def respond(
self,
human_input,
Expand Down
9 changes: 9 additions & 0 deletions vocode/streaming/streaming_conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,15 @@ async def terminate(self):
self.logger.debug("Tearing down synthesizer")
await self.synthesizer.tear_down()
self.logger.debug("Terminating agent")
if (
hasattr(self.agent.agent_config, "vector_db_config")
and self.agent.agent_config.vector_db_config
):
# Shutting down the vector db should be done in the agent's terminate method,
# but it is done here because `vector_db.tear_down()` is async and
# `agent.terminate()` is not async.
self.logger.debug("Terminating vector db")
await self.agent.vector_db.tear_down()
self.agent.terminate()
self.logger.debug("Terminating output device")
self.output_device.terminate()
Expand Down

0 comments on commit 9ebbc82

Please sign in to comment.