def __init__(
        self,
        *,
        mode: TokenStreamMode = TokenStreamMode.JSON,
        websocket: WebSocket = None,
        **kwargs: dict[str, Any],
    ) -> None:
        """Constructor method.

        Args:
            mode: The stream mode.
            websocket: The websocket to use.
            **kwargs: Keyword arguments to pass to the parent constructor.
        """
        super().__init__(**kwargs)

        if mode not in list(TokenStreamMode):
            raise ValueError(f"Invalid stream mode: {mode}")
        self.mode = mode

        self._websocket = websocket
        self.streaming = None
Constructor method.

        Args:
            mode: The stream mode.
            websocket: The websocket to use.
            **kwargs: Keyword arguments to pass to the parent constructor.
        
lanarky/adapters/langchain/callbacks.py