def uc_function_to_llama_tool(
        *,
        function_name: str,
        client: Optional[BaseFunctionClient] = None,
        return_direct: bool = False,
        filter_accessible_functions: bool = False,
    ) -> Optional[FunctionTool]:
        """
        Converts a Unity Catalog function into a Llama tool.

        Args:
            function_name (str): The name of the function in 'catalog.schema.function' format.
            client (Optional[BaseFunctionClient]): The client used to manage functions. Defaults to None.
            return_direct (Optional[bool]): Whether the tool should return the output directly. Defaults to False.

        Returns:
            FunctionTool: The constructed tool from the Unity Catalog function.
        """
        client = validate_or_set_default_client(client)

        if function_name is None:
            raise ValueError("function_name must be provided.")
        try:
            function_info = client.get_function(function_name)
        except PermissionError as e:
            _logger.info(f"Skipping {function_name} due to permission errors.")
            if filter_accessible_functions:
                return None
            raise e

        fn_schema = generate_function_input_params_schema(function_info)

        def func(**kwargs: Any) -> str:
            """
            Executes the Unity Catalog function with the provided parameters.

            Args:
                **kwargs (Any): Keyword arguments representing function parameters.

            Returns:
                str: The JSON result of the function execution.
            """
            kwargs = extract_properties(kwargs)
            args_json = json.loads(json.dumps(kwargs, default=str))
            result = client.execute_function(
                function_name=function_name,
                parameters=args_json,
                enable_retriever_tracing=mlflow_tracing_enabled("llama_index"),
            )
            return result.to_json()

        metadata = ToolMetadata(
            name=get_tool_name(function_name),
            description=function_info.comment or "",
            fn_schema=fn_schema.pydantic_model,
            return_direct=return_direct,
        )

        return UnityCatalogTool(
            fn=func,
            metadata=metadata,
            uc_function_name=function_name,
            client_config=client.to_dict(),
        )

        Converts a Unity Catalog function into a Llama tool.

        Args:
            function_name (str): The name of the function in 'catalog.schema.function' format.
            client (Optional[BaseFunctionClient]): The client used to manage functions. Defaults to None.
            return_direct (Optional[bool]): Whether the tool should return the output directly. Defaults to False.

        Returns:
            FunctionTool: The constructed tool from the Unity Catalog function.
        
ai/integrations/llama_index/src/unitycatalog/ai/llama_index/toolkit.py