def _extract_function_name(function_source: str) -> str:
    """
    Extracts the name of the first function defined in the provided source code
    using the ast module.
    """
    try:
        module_ast = ast.parse(textwrap.dedent(function_source))
    except SyntaxError as e:
        raise ValueError("Invalid Python source code") from e

    for node in module_ast.body:
        if isinstance(node, ast.FunctionDef):
            return node.name
    raise ValueError("No function definition found in the provided source code.")

    Extracts the name of the first function defined in the provided source code
    using the ast module.
    
ai/core/src/unitycatalog/ai/core/executor/local_subprocess.py