diff --git a/.changeset/curly-mails-think.md b/.changeset/curly-mails-think.md deleted file mode 100644 index e332229ef8..0000000000 --- a/.changeset/curly-mails-think.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"livekit-agents": patch ---- - -Fix split_paragraphs and simple-rag example diff --git a/.changeset/little-taxis-glow.md b/.changeset/little-taxis-glow.md deleted file mode 100644 index 69d45e661b..0000000000 --- a/.changeset/little-taxis-glow.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"livekit-agents": patch ---- - -Allow forcing interruptions of incomplete audio diff --git a/.changeset/shiny-rabbits-suffer.md b/.changeset/shiny-rabbits-suffer.md deleted file mode 100644 index e86e508be1..0000000000 --- a/.changeset/shiny-rabbits-suffer.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"livekit-plugins-openai": patch ---- - -add x.ai support diff --git a/examples/participant-entrypoint/requirements.txt b/examples/participant-entrypoint/requirements.txt index 8f568fa00b..170336f2dd 100644 --- a/examples/participant-entrypoint/requirements.txt +++ b/examples/participant-entrypoint/requirements.txt @@ -1 +1 @@ -livekit-agents>=0.10.1 +livekit-agents>=0.10.2 diff --git a/examples/simple-color/requirements.txt b/examples/simple-color/requirements.txt index 8f568fa00b..170336f2dd 100644 --- a/examples/simple-color/requirements.txt +++ b/examples/simple-color/requirements.txt @@ -1 +1 @@ -livekit-agents>=0.10.1 +livekit-agents>=0.10.2 diff --git a/examples/speech-to-text/requirements.txt b/examples/speech-to-text/requirements.txt index e8d61c73f6..ff15440e13 100644 --- a/examples/speech-to-text/requirements.txt +++ b/examples/speech-to-text/requirements.txt @@ -1,2 +1,2 @@ -livekit-agents>=0.10.1 +livekit-agents>=0.10.2 livekit-plugins-deepgram>=0.6.8 diff --git a/examples/text-to-speech/requirements.txt b/examples/text-to-speech/requirements.txt index 145113bc65..4c6fca4e40 100644 --- a/examples/text-to-speech/requirements.txt +++ b/examples/text-to-speech/requirements.txt @@ -1,4 +1,4 @@ -livekit-agents>=0.10.1 -livekit-plugins-openai>=0.10.3 +livekit-agents>=0.10.2 +livekit-plugins-openai>=0.10.4 livekit-plugins-cartesia>=0.4.2 livekit-plugins-elevenlabs>=0.7.5 diff --git a/examples/voice-pipeline-agent/requirements.txt b/examples/voice-pipeline-agent/requirements.txt index ccf03c6c63..eaedacc5db 100644 --- a/examples/voice-pipeline-agent/requirements.txt +++ b/examples/voice-pipeline-agent/requirements.txt @@ -1,5 +1,5 @@ -livekit-agents>=0.10.1 -livekit-plugins-openai>=0.10.3 +livekit-agents>=0.10.2 +livekit-plugins-openai>=0.10.4 livekit-plugins-deepgram>=0.6.8 livekit-plugins-silero>=0.7.1 livekit-plugins-rag>=0.2.2 diff --git a/livekit-agents/CHANGELOG.md b/livekit-agents/CHANGELOG.md index f615664e3e..eebad18196 100644 --- a/livekit-agents/CHANGELOG.md +++ b/livekit-agents/CHANGELOG.md @@ -1,5 +1,13 @@ # livekit-agents +## 0.10.2 + +### Patch Changes + +- Fix split_paragraphs and simple-rag example - [#896](https://github.com/livekit/agents/pull/896) ([@davidzhao](https://github.com/davidzhao)) + +- Allow forcing interruptions of incomplete audio - [#891](https://github.com/livekit/agents/pull/891) ([@martin-purplefish](https://github.com/martin-purplefish)) + ## 0.10.1 ### Patch Changes diff --git a/livekit-agents/livekit/agents/pipeline/pipeline_agent.py b/livekit-agents/livekit/agents/pipeline/pipeline_agent.py index 06fcc2ff5c..521338e7db 100644 --- a/livekit-agents/livekit/agents/pipeline/pipeline_agent.py +++ b/livekit-agents/livekit/agents/pipeline/pipeline_agent.py @@ -656,6 +656,10 @@ def _commit_user_question_if_needed() -> None: ) _commit_user_question_if_needed() + + if speech_handle.interrupted: + logger.warning(f"speech interrupted, quit loop") + break if speech_handle.interrupted: break diff --git a/livekit-agents/livekit/agents/version.py b/livekit-agents/livekit/agents/version.py index 2d44d066f0..d5ec5a9f34 100644 --- a/livekit-agents/livekit/agents/version.py +++ b/livekit-agents/livekit/agents/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.10.1" +__version__ = "0.10.2" diff --git a/livekit-agents/package.json b/livekit-agents/package.json index b46caa4398..0902339d13 100644 --- a/livekit-agents/package.json +++ b/livekit-agents/package.json @@ -1,5 +1,5 @@ { "name": "livekit-agents", "private": true, - "version": "0.10.1" + "version": "0.10.2" } diff --git a/livekit-plugins/livekit-plugins-openai/CHANGELOG.md b/livekit-plugins/livekit-plugins-openai/CHANGELOG.md index d1c6951252..6e889e85fa 100644 --- a/livekit-plugins/livekit-plugins-openai/CHANGELOG.md +++ b/livekit-plugins/livekit-plugins-openai/CHANGELOG.md @@ -1,5 +1,11 @@ # livekit-plugins-openai +## 0.10.4 + +### Patch Changes + +- add x.ai support - [#907](https://github.com/livekit/agents/pull/907) ([@theomonnom](https://github.com/theomonnom)) + ## 0.10.3 ### Patch Changes diff --git a/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/realtime_model.py b/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/realtime_model.py index aa02e51fc0..c537588b8a 100644 --- a/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/realtime_model.py +++ b/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/realtime_model.py @@ -770,43 +770,7 @@ def _queue_msg(self, msg: api_proto.ClientEvents) -> None: @utils.log_exceptions(logger=logger) async def _main_task(self) -> None: - try: - headers = {"User-Agent": "LiveKit Agents"} - query_params: dict[str, str] = {} - - base_url = self._opts.base_url - if self._opts.is_azure: - if self._opts.entra_token: - headers["Authorization"] = f"Bearer {self._opts.entra_token}" - - if self._opts.api_key: - headers["api-key"] = self._opts.api_key - - if self._opts.api_version: - query_params["api-version"] = self._opts.api_version - - if self._opts.azure_deployment: - query_params["deployment"] = self._opts.azure_deployment - else: - # OAI endpoint - headers["Authorization"] = f"Bearer {self._opts.api_key}" - headers["OpenAI-Beta"] = "realtime=v1" - - if self._opts.model: - query_params["model"] = self._opts.model - - url = f"{base_url.rstrip('/')}/realtime?{urlencode(query_params)}" - if url.startswith("http"): - url = url.replace("http", "ws", 1) - - ws_conn = await self._http_session.ws_connect( - url, - headers=headers, - ) - except Exception: - logger.exception("failed to connect to OpenAI API S2S") - return - + closing = False @utils.log_exceptions(logger=logger) @@ -890,16 +854,58 @@ async def _recv_task(): "failed to handle OpenAI S2S message", extra={"websocket_message": msg, **self.logging_extra()}, ) + + while not closing: + try: + headers = {"User-Agent": "LiveKit Agents"} + query_params: dict[str, str] = {} + + base_url = self._opts.base_url + if self._opts.is_azure: + if self._opts.entra_token: + headers["Authorization"] = f"Bearer {self._opts.entra_token}" + + if self._opts.api_key: + headers["api-key"] = self._opts.api_key + + if self._opts.api_version: + query_params["api-version"] = self._opts.api_version + + if self._opts.azure_deployment: + query_params["deployment"] = self._opts.azure_deployment + else: + # OAI endpoint + headers["Authorization"] = f"Bearer {self._opts.api_key}" + headers["OpenAI-Beta"] = "realtime=v1" + + if self._opts.model: + query_params["model"] = self._opts.model + + url = f"{base_url.rstrip('/')}/realtime?{urlencode(query_params)}" + if url.startswith("http"): + url = url.replace("http", "ws", 1) + + ws_conn = await self._http_session.ws_connect( + url, + headers=headers, + ) + except Exception: + logger.exception("failed to connect to OpenAI API S2S") + return + - tasks = [ - asyncio.create_task(_send_task(), name="openai-realtime-send"), - asyncio.create_task(_recv_task(), name="openai-realtime-recv"), - ] + tasks = [ + asyncio.create_task(_send_task(), name="openai-realtime-send"), + asyncio.create_task(_recv_task(), name="openai-realtime-recv"), + ] - try: - await asyncio.gather(*tasks) - finally: - await utils.aio.gracefully_cancel(*tasks) + try: + await asyncio.gather(*tasks) + except Exception: + logger.exception("Exception occurred during the OpenAI API S2S process. Try to reconnect.") + continue + finally: + await utils.aio.gracefully_cancel(*tasks) def _handle_session_created( self, session_created: api_proto.ServerEvent.SessionCreated diff --git a/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/version.py b/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/version.py index ba63387bc0..7b439e4ece 100644 --- a/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/version.py +++ b/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.10.3" +__version__ = "0.10.4" diff --git a/livekit-plugins/livekit-plugins-openai/package.json b/livekit-plugins/livekit-plugins-openai/package.json index c2d391b135..9db1eb583f 100644 --- a/livekit-plugins/livekit-plugins-openai/package.json +++ b/livekit-plugins/livekit-plugins-openai/package.json @@ -1,5 +1,5 @@ { "name": "livekit-plugins-openai", "private": true, - "version": "0.10.3" + "version": "0.10.4" }