From 1edadfc8fa53a12c439bb1432355f78050a03364 Mon Sep 17 00:00:00 2001 From: zhangqianze Date: Wed, 4 Dec 2024 00:01:18 +0800 Subject: [PATCH] fix: fix v2v greeting bug --- .../ten_packages/extension/openai_v2v_python/extension.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/agents/ten_packages/extension/openai_v2v_python/extension.py b/agents/ten_packages/extension/openai_v2v_python/extension.py index 61912b23..043be3ed 100644 --- a/agents/ten_packages/extension/openai_v2v_python/extension.py +++ b/agents/ten_packages/extension/openai_v2v_python/extension.py @@ -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 @@ -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 @@ -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())