From 2dd11702292860b00226f18ed5e0de60c26eae84 Mon Sep 17 00:00:00 2001 From: filipi87 Date: Thu, 9 Apr 2026 17:26:51 -0300 Subject: [PATCH] Updating the Anthropic stream example to allow cancel the location tracking. --- .../function-calling-anthropic-async-stream.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/examples/function-calling/function-calling-anthropic-async-stream.py b/examples/function-calling/function-calling-anthropic-async-stream.py index 953855da0..e96a56442 100644 --- a/examples/function-calling/function-calling-anthropic-async-stream.py +++ b/examples/function-calling/function-calling-anthropic-async-stream.py @@ -118,6 +118,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = AnthropicLLMService( api_key=os.getenv("ANTHROPIC_API_KEY"), + enable_async_tool_cancellation=True, settings=AnthropicLLMService.Settings( system_instruction=( "You are a helpful assistant in a voice conversation. " @@ -139,10 +140,6 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): timeout_secs=30, ) - @llm.event_handler("on_function_calls_started") - async def on_function_calls_started(service, function_calls): - await tts.queue_frame(TTSSpeakFrame("Sure, tracking your location now.")) - location_function = FunctionSchema( name="track_current_location", description="Start tracking the user's current GPS location, reporting position updates until the user reaches their destination.",