def uc_function_to_crewai_tool(
        *,
        function_name: str,
        client: Optional[BaseFunctionClient] = None,
        description_updated: Optional[bool] = False,
        cache_function: Callable = lambda _args, _result: True,
        result_as_answer: bool = False,
        filter_accessible_functions: bool = False,
        **kwargs,
    ) -> Optional[CrewAIBaseTool]:
        """
        Converts a Unity Catalog function into a CrewAI tool.

        Args:
            function_name (str): Name of the function to convert.
            client (Optional[BaseFunctionClient]): Client for executing the function.
            description_updated (Optional[Bool]): Flag to check if the description has been updated.
            cache_function (Optional[Callable]): Function that will be used to determine if the tool
                should be cached, should return a boolean. If None, the tool will be cached.
            result_as_answer (Optional[Bool]): Flag to check if the tool should be the final
                agent answer.

        Returns:
            CrewAIBaseTool: A tool representation of 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

        def func(**kwargs: Any) -> str:
            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("crewai"),
            )

            return result.to_json()

        generated_model = generate_function_input_params_schema(function_info).pydantic_model

        if generated_model == BaseModel:
            # NB: Pydantic BaseModel.schema(), which is used by CrewAI, requires a subclass
            # of BaseClass. When function_info.input_params is None, we return a BaseModel as the
            # pydantic_model
            class _BaseModelWrapper(generated_model): ...

            generated_model = _BaseModelWrapper

        return UnityCatalogTool(
            # UnityCatalogTool params
            fn=func,
            client_config=client.to_dict(),
            # CrewAI params from UC
            name=get_tool_name(function_name),
            description=function_info.comment or "",
            args_schema=generated_model,
            # CrewAI params from user
            description_updated=description_updated,
            cache_function=cache_function,
            result_as_answer=result_as_answer,
        )

        Converts a Unity Catalog function into a CrewAI tool.

        Args:
            function_name (str): Name of the function to convert.
            client (Optional[BaseFunctionClient]): Client for executing the function.
            description_updated (Optional[Bool]): Flag to check if the description has been updated.
            cache_function (Optional[Callable]): Function that will be used to determine if the tool
                should be cached, should return a boolean. If None, the tool will be cached.
            result_as_answer (Optional[Bool]): Flag to check if the tool should be the final
                agent answer.

        Returns:
            CrewAIBaseTool: A tool representation of the Unity Catalog function.
        
ai/integrations/crewai/src/unitycatalog/ai/crewai/toolkit.py