import aiohttp async def download_file_for_task(task_id: str, api_base_url: str) -> bytes: """ Asynchronously downloads a specific file associated with a given task ID. This function performs a GET request to the endpoint /files/{task_id}. Args: task_id: The identifier of the task for which to download the file. api_base_url: The base URL of the API. Returns: The content of the file as bytes. Raises: aiohttp.ClientResponseError: If the API returns an error status (e.g., 404 Not Found, 500 Internal Server Error). aiohttp.ClientError: For other client-side errors, such as network connection issues. """ url = f"{api_base_url}/files/{task_id}" async with aiohttp.ClientSession() as session: async with session.get(url) as response: response.raise_for_status() # Raise an exception for HTTP error codes (4xx or 5xx) file_bytes = await response.read() return file_bytes