def extract_numbers_given_response(response: str, n: int = 1) -> Optional[List[int]]:
    """
    Extract number given the GPT-generated response.

    Used by tree-structured indices.

    """
    numbers = re.findall(r"\d+", response)
    if len(numbers) == 0:
        return None
    else:
        return numbers[:n]

    Extract number given the GPT-generated response.

    Used by tree-structured indices.

    
llama-index-core/llama_index/core/indices/utils.py