INNER CODE UNIT · Python

add_message_handler

dusty-nv/jetson-containers · packages/llm/local_llm/web/server.py:136

    def add_message_handler(self, callback):
        """
        Register a message handler that will be called when new websocket messages are recieved
        """
        if callback:
            self.msg_callback.append(callback)
            
    def on_message(self, payload, payload_size=None, msg_type=MESSAGE_JSON, msg_id=None, metadata=None, timestamp=None, path=None, **kwargs):
        """
        Handler for recieved websocket messages. Implement this in a subclass to process messages,
        otherwise msg_callback needs to be provided during initialization.
        
        Parameters:
        
          payload (dict|str|bytes) -- If this is a JSON message, will be a dict.
                                      If this is a text message, will be a string.
                                      If this is a binary message, will be a bytes array.  
                                      

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…