From 9e9822f17d44591965029a5a1483055fa266b662 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Mon, 27 Jan 2025 10:23:26 -0500 Subject: [PATCH] Use inspect.signature to determine which callback to use --- src/pipecat/processors/user_idle_processor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pipecat/processors/user_idle_processor.py b/src/pipecat/processors/user_idle_processor.py index 9339e2481..7c2f1c763 100644 --- a/src/pipecat/processors/user_idle_processor.py +++ b/src/pipecat/processors/user_idle_processor.py @@ -5,6 +5,7 @@ # import asyncio +import inspect from typing import Awaitable, Callable, Union from pipecat.frames.frames import ( @@ -85,9 +86,11 @@ class UserIdleProcessor(FrameProcessor): Returns: A wrapped callback that returns bool to indicate whether to continue monitoring. """ + sig = inspect.signature(callback) + param_count = len(sig.parameters) async def wrapper(processor: "UserIdleProcessor", retry_count: int) -> bool: - if len(callback.__code__.co_varnames) == 1: + if param_count == 1: # Basic callback await callback(processor) # type: ignore return True