Class MemoryRecord


  • public class MemoryRecord
    extends DataEntryBase
    A record in a Semantic Kernel memory. IMPORTANT: this is a storage schema. Changing the fields will invalidate existing metadata stored in persistent vector DBs.
    • Method Detail

      • getEmbedding

        public Embedding<? extends Number> getEmbedding()
        Gets the source content embeddings.
        Returns:
        The source content embeddings.
      • getMetadata

        public MemoryRecordMetadata getMetadata()
        Gets the metadata associated with a Semantic Kernel memory.
        Returns:
        The metadata associated with a Semantic Kernel memory.
      • referenceRecord

        public static MemoryRecord referenceRecord​(@Nonnull
                                                   String externalId,
                                                   @Nonnull
                                                   String sourceName,
                                                   @Nullable
                                                   String description,
                                                   @Nonnull
                                                   Embedding<Float> embedding,
                                                   @Nullable
                                                   String additionalMetadata,
                                                   @Nullable
                                                   String key,
                                                   @Nullable
                                                   ZonedDateTime timestamp)
        Prepare an instance about a memory which source is stored externally. The universal resource identifies points to the URL (or equivalent) to find the original source.
        Parameters:
        externalId - URL (or equivalent) to find the original source.
        sourceName - Name of the external service, e.g. "MSTeams", "GitHub", "WebSite", "Outlook IMAP", etc.
        description - Optional description of the record. Note: the description is not indexed.
        embedding - Source content embedding.
        additionalMetadata - Optional string for saving custom metadata.
        key - Optional existing database key.
        timestamp - optional timestamp.
        Returns:
        Memory record
      • localRecord

        public static MemoryRecord localRecord​(@Nonnull
                                               String id,
                                               @Nonnull
                                               String text,
                                               @Nullable
                                               String description,
                                               @Nonnull
                                               Embedding<Float> embedding,
                                               @Nullable
                                               String additionalMetadata,
                                               @Nullable
                                               String key,
                                               @Nullable
                                               ZonedDateTime timestamp)
        Prepare an instance for a memory stored in the internal storage provider.
        Parameters:
        id - Resource identifier within the storage provider, e.g. record ID/GUID/incremental counter etc.
        text - Full text used to generate the embeddings.
        description - Optional description of the record. Note: the description is not indexed.
        embedding - Source content embedding.
        additionalMetadata - Optional string for saving custom metadata.
        key - Optional existing database key.
        timestamp - optional timestamp.
        Returns:
        Memory record
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object