def dashscope_response_handler(
    response: Response, process: str, result_class: Type[T], url: str = ""
) -> T:
    """Handle the response from the DashScope API."""
    if response is None:
        raise ValueError(
            f"DashScopeParse {process} [URL:{url}] http response object is none."
        )

    if not isinstance(process, str) or not process:
        raise ValueError(
            "DashScopeParse func [dashscope_response_handler] process parameter is empty."
        )

    if response.status_code != 200:
        logger.error(
            f"DashScopeParse {process} [URL:{url}] response http status code is not 200: [{response.status_code}:{response.text}]"
        )
        if response.status_code == 429:
            __raise_exception_for_retry(response, process)
        __raise_exception(response, process)
    try:
        response_data = response.json()
    except Exception as e:
        logger.error(
            f"DashScopeParse {process} [URL:{url}] response data is not json: {response.text}."
        )
        __raise_exception(response, process)

    if not __is_response_successful(response_data):
        logger.error(
            f"DashScopeParse {process} [URL:{url}] response fail: {response.text}."
        )
        __raise_exception(response, process)

    if "data" not in response_data:
        logger.error(
            f"DashScopeParse {process} [URL:{url}] response data does not contain 'data' key: {response_data}."
        )
        __raise_exception(response, process)
    if "request_id" in response_data and process != "query":
        logger.info(
            f"DashScopeParse {process} [URL:{url}] request_id: {response_data['request_id']}."
        )
    return result_class.from_dict(response_data["data"])
Handle the response from the DashScope API.
llama-index-integrations/readers/llama-index-readers-dashscope/llama_index/readers/dashscope/utils.py