def to_function_calling_config()

in google/generativeai/types/content_types.py [0:0]


def to_function_calling_config(obj: FunctionCallingConfigType) -> protos.FunctionCallingConfig:
    if isinstance(obj, protos.FunctionCallingConfig):
        return obj
    elif isinstance(obj, (FunctionCallingMode, str, int)):
        obj = {"mode": to_function_calling_mode(obj)}
    elif isinstance(obj, dict):
        obj = obj.copy()
        mode = obj.pop("mode")
        obj["mode"] = to_function_calling_mode(mode)
    else:
        raise TypeError(
            "Invalid input type. Failed to convert input to `protos.FunctionCallingConfig`.\n"
            f"Received an object of type: {type(obj)}.\n"
            f"Object Value: {obj}"
        )

    return protos.FunctionCallingConfig(obj)