Class MemoryRecord
- java.lang.Object
-
- com.microsoft.semantickernel.memory.DataEntryBase
-
- com.microsoft.semantickernel.memory.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.
-
-
Constructor Summary
Constructors Constructor Description MemoryRecord(MemoryRecordMetadata metadata, Embedding<? extends Number> embedding, String key, ZonedDateTime timestamp)Creates an instance of aMemoryRecord.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)static MemoryRecordfromMetadata(MemoryRecordMetadata metadata, Embedding<Float> embedding, String key, ZonedDateTime timestamp)Create a memory record from a memory record's metadata.Embedding<? extends Number>getEmbedding()Gets the source content embeddings.MemoryRecordMetadatagetMetadata()Gets the metadata associated with a Semantic Kernel memory.inthashCode()static MemoryRecordlocalRecord(String id, String text, String description, Embedding<Float> embedding, String additionalMetadata, String key, ZonedDateTime timestamp)Prepare an instance for a memory stored in the internal storage provider.static MemoryRecordreferenceRecord(String externalId, String sourceName, String description, Embedding<Float> embedding, String additionalMetadata, String key, ZonedDateTime timestamp)Prepare an instance about a memory which source is stored externally.StringtoString()-
Methods inherited from class com.microsoft.semantickernel.memory.DataEntryBase
getKey, getTimestamp
-
-
-
-
Constructor Detail
-
MemoryRecord
public MemoryRecord(@Nonnull MemoryRecordMetadata metadata, @Nonnull Embedding<? extends Number> embedding, @Nullable String key, @Nullable ZonedDateTime timestamp)
Creates an instance of aMemoryRecord.- Parameters:
metadata- The metadata associated with a Semantic Kernel memory.embedding- The source content embeddings.key- The key of the data.timestamp- The timestamp of the data.
-
-
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
-
fromMetadata
public static MemoryRecord fromMetadata(@Nonnull MemoryRecordMetadata metadata, @Nullable Embedding<Float> embedding, @Nullable String key, @Nullable ZonedDateTime timestamp)
Create a memory record from a memory record's metadata.- Parameters:
metadata- Metadata associated with a memory.embedding- Optional embedding associated with a memory record.key- Optional existing database key.timestamp- optional timestamp.- Returns:
- Memory record
-
-