Skip to content

get_context_params

autogen.tools.dependency_injection.get_context_params #

get_context_params(func, subclass)

Gets the names of the context parameters in a function signature.

PARAMETER DESCRIPTION
func

The function to inspect for context parameters.

TYPE: Callable[..., Any]

subclass

The subclass to search for.

TYPE: Union[type[BaseContext], type[ChatContext]]

RETURNS DESCRIPTION
list[str]

A list of parameter names that are instances of the specified subclass.

Source code in autogen/tools/dependency_injection.py
def get_context_params(func: Callable[..., Any], subclass: Union[type[BaseContext], type[ChatContext]]) -> list[str]:
    """Gets the names of the context parameters in a function signature.

    Args:
        func: The function to inspect for context parameters.
        subclass: The subclass to search for.

    Returns:
        A list of parameter names that are instances of the specified subclass.
    """
    sig = inspect.signature(func)
    return [p.name for p in sig.parameters.values() if _is_context_param(p, subclass=subclass)]