def get_token_data(token: str, mode: TokenStreamMode) -> str:
    """Get token data based on mode.

    Args:
        token: The token to use.
        mode: The stream mode.
    """
    if mode not in list(TokenStreamMode):
        raise ValueError(f"Invalid stream mode: {mode}")

    if mode == TokenStreamMode.TEXT:
        return token
    else:
        return model_dump_json(TokenEventData(token=token))
Get token data based on mode.

    Args:
        token: The token to use.
        mode: The stream mode.
    
lanarky/adapters/langchain/callbacks.py