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

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

    Returns:
        Tuple[str, str, str]: Extracted thought, action, and action input.

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

    """
    pattern = (
        r"\s*Thought: (.*?)\nAction: ([a-zA-Z0-9_]+).*?\nAction Input: .*?(\{.*\})"
    )

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

    thought = match.group(1).strip()
    action = match.group(2).strip()
    action_input = match.group(3).strip()
    return thought, action, action_input

    Extract thought, action, and action input from the input text.

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

    Returns:
        Tuple[str, str, str]: Extracted thought, action, and action input.

    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