def get_function_calls(response: GenerateContentResponse) -> list[protos.FunctionCall]:
    """
    Extracts function calls from a given GenerateContentResponse.

    Args:
        response (GenerateContentResponse): The response object returned by the model's generation call.

    Returns:
        list[protos.FunctionCall]: A list of FunctionCall objects extracted from the single candidate's response.
    """

    candidates = response.candidates
    if len(candidates) != 1:
        raise ValueError(
            f"Invalid number of candidates: Automatic function calling only works with "
            f"1 candidate, but {len(candidates)} were provided."
        )
    parts = candidates[0].content.parts

    function_calls = [part.function_call for part in parts if part and "function_call" in part]
    return function_calls

    Extracts function calls from a given GenerateContentResponse.

    Args:
        response (GenerateContentResponse): The response object returned by the model's generation call.

    Returns:
        list[protos.FunctionCall]: A list of FunctionCall objects extracted from the single candidate's response.
    
ai/integrations/gemini/src/unitycatalog/ai/gemini/utils.py