Class SemanticChatMessage

java.lang.Object
com.redis.vl.extensions.messagehistory.SemanticChatMessage

public final class SemanticChatMessage extends Object
A chat message with vector embedding for semantic search.

Extends the ChatMessage model with a vector field for storing embeddings. Matches the Python ChatMessage model from redisvl.extensions.message_history.schema when used with SemanticMessageHistory.

This class is final to prevent finalizer attacks (SEI CERT OBJ11-J).

  • Constructor Details

    • SemanticChatMessage

      public SemanticChatMessage()
  • Method Details

    • toDict

      public Map<String,Object> toDict(String dtype)
      Converts the SemanticChatMessage to a Map suitable for storing in Redis.
      Parameters:
      dtype - The data type for the vector field (e.g., "float32")
      Returns:
      Map representation of the message
    • toDict

      public Map<String,Object> toDict()
      Converts the SemanticChatMessage to a Map using default float32 dtype.
      Returns:
      Map representation of the message
    • fromDict

      public static SemanticChatMessage fromDict(Map<String,Object> data)
      Creates a SemanticChatMessage from a Map (typically from Redis).
      Parameters:
      data - Map containing message fields
      Returns:
      SemanticChatMessage instance