Use inspect.signature to determine which callback to use

This commit is contained in:
Mark Backman
2025-01-27 10:23:26 -05:00
parent 5f9671e2ca
commit 9e9822f17d

View File

@@ -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