diff --git a/examples/function-calling/function-calling-anthropic-async-stream.py b/examples/function-calling/function-calling-anthropic-async-stream.py index e96a56442..8dc62481a 100644 --- a/examples/function-calling/function-calling-anthropic-async-stream.py +++ b/examples/function-calling/function-calling-anthropic-async-stream.py @@ -140,6 +140,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): timeout_secs=30, ) + @llm.event_handler("on_function_calls_cancelled") + async def on_function_calls_cancelled(service, cancelled): + for item in cancelled: + logger.info(f"Function call cancelled: {item.function_name} [{item.tool_call_id}]") + 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.", diff --git a/examples/function-calling/function-calling-anthropic-async.py b/examples/function-calling/function-calling-anthropic-async.py index b727cbd13..62baaaa1b 100644 --- a/examples/function-calling/function-calling-anthropic-async.py +++ b/examples/function-calling/function-calling-anthropic-async.py @@ -93,6 +93,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm.register_function("get_restaurant_recommendation", fetch_restaurant_recommendation) + @llm.event_handler("on_function_calls_cancelled") + async def on_function_calls_cancelled(service, cancelled): + for item in cancelled: + logger.info(f"Function call cancelled: {item.function_name} [{item.tool_call_id}]") + weather_function = FunctionSchema( name="get_current_weather", description="Get the current weather", diff --git a/examples/function-calling/function-calling-google-async-stream.py b/examples/function-calling/function-calling-google-async-stream.py index c8d0f87db..63c83318e 100644 --- a/examples/function-calling/function-calling-google-async-stream.py +++ b/examples/function-calling/function-calling-google-async-stream.py @@ -144,6 +144,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_function_calls_started(service, function_calls): await tts.queue_frame(TTSSpeakFrame("Sure, tracking your location now.")) + @llm.event_handler("on_function_calls_cancelled") + async def on_function_calls_cancelled(service, cancelled): + for item in cancelled: + logger.info(f"Function call cancelled: {item.function_name} [{item.tool_call_id}]") + 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.", diff --git a/examples/function-calling/function-calling-google-async.py b/examples/function-calling/function-calling-google-async.py index 6892d4abd..89bae24d4 100644 --- a/examples/function-calling/function-calling-google-async.py +++ b/examples/function-calling/function-calling-google-async.py @@ -141,6 +141,11 @@ indicate you should use the get_image tool are: async def on_function_calls_started(service, function_calls): await tts.queue_frame(TTSSpeakFrame("Let me check on that.")) + @llm.event_handler("on_function_calls_cancelled") + async def on_function_calls_cancelled(service, cancelled): + for item in cancelled: + logger.info(f"Function call cancelled: {item.function_name} [{item.tool_call_id}]") + weather_function = FunctionSchema( name="get_weather", description="Get the current weather", diff --git a/examples/function-calling/function-calling-openai-async-stream.py b/examples/function-calling/function-calling-openai-async-stream.py index 1a3a6317b..fd2caaddf 100644 --- a/examples/function-calling/function-calling-openai-async-stream.py +++ b/examples/function-calling/function-calling-openai-async-stream.py @@ -144,6 +144,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_function_calls_started(service, function_calls): await tts.queue_frame(TTSSpeakFrame("Sure, tracking your location now.")) + @llm.event_handler("on_function_calls_cancelled") + async def on_function_calls_cancelled(service, cancelled): + for item in cancelled: + logger.info(f"Function call cancelled: {item.function_name} [{item.tool_call_id}]") + 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.", diff --git a/examples/function-calling/function-calling-openai-async.py b/examples/function-calling/function-calling-openai-async.py index 7a7bd5ddd..50efa25e9 100644 --- a/examples/function-calling/function-calling-openai-async.py +++ b/examples/function-calling/function-calling-openai-async.py @@ -107,6 +107,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_function_calls_started(service, function_calls): await tts.queue_frame(TTSSpeakFrame("Let me check on that.")) + @llm.event_handler("on_function_calls_cancelled") + async def on_function_calls_cancelled(service, cancelled): + for item in cancelled: + logger.info(f"Function call cancelled: {item.function_name} [{item.tool_call_id}]") + weather_function = FunctionSchema( name="get_current_weather", description="Get the current weather", diff --git a/examples/function-calling/function-calling-openai-responses-async-stream.py b/examples/function-calling/function-calling-openai-responses-async-stream.py index 5bdde5cb3..093e0d47b 100644 --- a/examples/function-calling/function-calling-openai-responses-async-stream.py +++ b/examples/function-calling/function-calling-openai-responses-async-stream.py @@ -144,6 +144,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_function_calls_started(service, function_calls): await tts.queue_frame(TTSSpeakFrame("Sure, tracking your location now.")) + @llm.event_handler("on_function_calls_cancelled") + async def on_function_calls_cancelled(service, cancelled): + for item in cancelled: + logger.info(f"Function call cancelled: {item.function_name} [{item.tool_call_id}]") + location_function = FunctionSchema( name="track_current_location", description="Track the device's current GPS location during a road trip, reporting position updates as the vehicle moves through cities until it reaches the final destination.", diff --git a/examples/function-calling/function-calling-openai-responses-async.py b/examples/function-calling/function-calling-openai-responses-async.py index 16b21f212..8e6fb3fa9 100644 --- a/examples/function-calling/function-calling-openai-responses-async.py +++ b/examples/function-calling/function-calling-openai-responses-async.py @@ -105,6 +105,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # matching, forcing a full context resend. await tts.queue_frame(TTSSpeakFrame("Let me check on that.", append_to_context=False)) + @llm.event_handler("on_function_calls_cancelled") + async def on_function_calls_cancelled(service, cancelled): + for item in cancelled: + logger.info(f"Function call cancelled: {item.function_name} [{item.tool_call_id}]") + weather_function = FunctionSchema( name="get_current_weather", description="Get the current weather",