def extract_final_response(input_text: str) -> Tuple[str, str]:
    """
    Extract the thought and answer from the input text.

    Args:
        input_text (str): The text from which to extract the components.

    Returns:
        Tuple[str, str]: Extracted thought and answer.

    Raises:
        ValueError: If the input text does not contain the required information.

    """
    pattern = r"\s*Thought:(.*?)Answer:(.*?)(?:$)"

    match = re.search(pattern, input_text, re.DOTALL)
    if not match:
        raise ValueError(
            f"Could not extract final answer from input text: {input_text}"
        )

    thought = match.group(1).strip()
    answer = match.group(2).strip()
    return thought, answer

    Extract the thought and answer from the input text.

    Args:
        input_text (str): The text from which to extract the components.

    Returns:
        Tuple[str, str]: Extracted thought and answer.

    Raises:
        ValueError: If the input text does not contain the required information.

    
llama-index-packs/llama-index-packs-secgpt/llama_index/packs/secgpt/spoke_parser.py