def base_endpoint(self, func: Callable):
        """
        A decorator to wrap endpoints in a standard pattern:
         - error handling
         - response shaping
        """

        @functools.wraps(func)
        async def wrapper(*args, **kwargs):
            try:
                func_result = await func(*args, **kwargs)
                if isinstance(func_result, tuple) and len(func_result) == 2:
                    results, outer_kwargs = func_result
                else:
                    results, outer_kwargs = func_result, {}

                if isinstance(results, (StreamingResponse, FileResponse)):
                    return results
                return {"results": results, **outer_kwargs}

            except R2RException:
                raise
            except Exception as e:
                logger.error(
                    f"Error in base endpoint {func.__name__}() - {str(e)}",
                    exc_info=True,
                )
                raise HTTPException(
                    status_code=500,
                    detail={
                        "message": f"An error '{e}' occurred during {func.__name__}",
                        "error": str(e),
                        "error_type": type(e).__name__,
                    },
                ) from e

        wrapper._is_base_endpoint = True  # type: ignore
        return wrapper

        A decorator to wrap endpoints in a standard pattern:
         - error handling
         - response shaping
        
py/core/main/api/v3/base_router.py