From 4809684a136afbd745501890a8cc3bf160033754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Mon, 28 Apr 2025 14:12:26 -0700 Subject: [PATCH] LLMService: cancel function calls on interruptions by default --- CHANGELOG.md | 6 ++++++ src/pipecat/services/llm_service.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc8a43bdd..8d5bb1bb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Function calls are now cancelled by default if there's an interruption. To + disable this behavior you can set `cancel_on_interruption=False` when + registering the function call. Since function calls are executed as tasks you + can tell if a function call has been cancelled by catching the + `asyncio.CancelledError` exception (and don't forget to raise it again!). + - Updated OpenTelemetry tracing attribute `metrics.ttfb_ms` to `metrics.ttfb`. The attribute reports TTFB in seconds. diff --git a/src/pipecat/services/llm_service.py b/src/pipecat/services/llm_service.py index 69eabc686..2a94598fa 100644 --- a/src/pipecat/services/llm_service.py +++ b/src/pipecat/services/llm_service.py @@ -181,7 +181,7 @@ class LLMService(AIService): handler: Any, start_callback=None, *, - cancel_on_interruption: bool = False, + cancel_on_interruption: bool = True, ): # Registering a function with the function_name set to None will run # that handler for all functions