Skip to content

Commit

Permalink
fix: fix v2v greeting bug
Browse files Browse the repository at this point in the history
  • Loading branch information
plutoless committed Dec 3, 2024
1 parent 10aad18 commit 1edadfc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions agents/ten_packages/extension/openai_v2v_python/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ async def on_cmd(self, ten_env: AsyncTenEnv, cmd: Cmd) -> None:
elif cmd_name == CMD_IN_ON_USER_JOINED:
self.users_count += 1
# Send greeting when first user joined
if self.connected and self.users_count == 1:
if self.users_count == 1:
await self._greeting()
elif cmd_name == CMD_IN_ON_USER_LEFT:
self.users_count -= 1
Expand Down Expand Up @@ -217,7 +217,6 @@ def get_time_ms() -> int:
# self.ten_env.log_info(f"Received message: {message.type}")
match message:
case SessionCreated():
self.connected = True
self.ten_env.log_info(f"Session is created: {message.session}")
self.session_id = message.session.id
self.session = message.session
Expand Down Expand Up @@ -610,8 +609,11 @@ def _convert_to_content_parts(self, content: Iterable[LLMChatCompletionContentPa
return content_parts

async def _greeting(self) -> None:
if self.config.greeting:
if self.connected and self.users_count == 1:
text = self._greeting_text()
if self.config.greeting:
text = self.config.greeting
self.ten_env.log_info(f"send greeting {text}")
await self.conn.send_request(ItemCreate(item=UserMessageItemParam(content=[{"type": ContentType.InputText, "text": text}])))
await self.conn.send_request(ResponseCreate())

Expand Down

0 comments on commit 1edadfc

Please sign in to comment.