<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 async def detach_tip(data):
 """ Detach the tip from the current pipette :param data: Information obtained from a POST request. The content type is application/json. The correct packet form should be as follows: { 'token': UUID token from current session start 'command': 'detach tip' } """

    global session

    if not feature_flags.use_protocol_api_v2():
        pipette = session.pipettes[session.current_mount]
        if not pipette.tip_attached:
            log.warning('detach tip called with no tip')
        pipette._remove_tip(session.tip_length)
    else:
        session.adapter.remove_tip(session.current_mount)
        if session.cp:
            session.cp = CriticalPoint.NOZZLE
    session.tip_length = None

    return web.json_response({'message': "Tip removed"}, status=200)