OpenSearchMemory / Client / update_memory
update_memory¶
- OpenSearchMemory.Client.update_memory(**kwargs)¶
Updates a memory in place. Supply only the fields to change. Omitted fields keep their stored values. A request must supply
contentormetadata, or it fails withValidationException. Supplyingcontentre-embeds the memory. A change to metadata alone doesn’t.The memory keeps its
memoryIdacross updates. Shortly after an update, searches stop returning the previous content.memoryTypecan’t be changed. To change it, delete the memory and create a new one.A memory past its expiry (set from the space’s
memoryExpiryDayswhen the memory is written) reads as not found: the operation fails withResourceNotFoundExceptionand changes nothing. An update does not move the expiry.Concurrent updates to one memory are last-writer-wins. There is no version check. To avoid lost updates, serialize your updates to a memory.
If you supply
contentand the request would exceed the service’s rate for embedding requests, it fails withThrottlingException. Retry with exponential backoff.If the space uses a customer managed AWS KMS key, the call can also fail because of the key. It fails with
AccessDeniedExceptionif you aren’t allowed to use the key, and withThrottlingExceptionif AWS KMS throttles the request. It fails withValidationExceptionif the key is disabled, pending deletion, or deleted.See also: AWS API Documentation
Request Syntax
response = client.update_memory( spaceId='string', memoryId='string', content='string', metadata={ 'string': 'string' }, metadataMode='REPLACE'|'MERGE', actorId='string', strategyName='string' )
- Parameters:
spaceId (string) –
[REQUIRED]
The ID of the space that owns the memory, for example
sp-02864597b164.memoryId (string) –
[REQUIRED]
The ID of the memory to update.
content (string) – Replacement memory text. Supplying it re-embeds the memory. Omit to leave the text unchanged.
metadata (dict) –
The metadata tags to apply. By default this map replaces the stored metadata, and any key not present is removed. Set
metadataModetoMERGEto keep the keys you don’t supply. Limits apply to the resulting metadata, not to the request. Keys that begin withx-amz-and the keydocumentS3Sourceare reserved: a request that sets one fails withValidationException.A space can use at most 50 distinct metadata keys across all of its events and memories. A request that would add a key beyond that fails with
ValidationException. Reuse an existing key instead.(string) –
A metadata key: letters, digits, hyphens (
-), and underscores (_). Dots are not allowed, because a query uses dots to separate nested field names.(string) –
The value of a metadata entry.
metadataMode (string) – How
metadatacombines with what is stored. The default isREPLACE.actorId (string) – The ID of the actor that the memory must belong to. Omit it to skip this check. If it doesn’t match the stored memory, the call fails with
ResourceNotFoundException, as if the memory did not exist.strategyName (string) – The name of the strategy that the memory must belong to. Omit it to skip this check. If it doesn’t match the stored memory, the call fails with
ResourceNotFoundException, as if the memory did not exist.
- Return type:
dict
- Returns:
Response Syntax
{ 'memory': { 'memoryId': 'string', 'memoryType': 'SEMANTIC'|'SUMMARY'|'CUSTOM', 'strategyName': 'string', 'content': 'string', 'systemMetadata': { 'actorId': 'string', 'sessionId': 'string', 'createdAt': datetime(2015, 1, 1), 'updatedAt': datetime(2015, 1, 1) }, 'metadata': { 'string': 'string' } } }
Response Structure
(dict) –
memory (dict) –
The updated memory, in the same shape that
GetMemoryreturns.memoryId (string) –
The memory’s ID, assigned by the service.
memoryType (string) –
The memory type.
strategyName (string) –
The name of the strategy the memory belongs to, for example
user-facts. A space can hold several strategies of the same type, so this tells them apart. Absent when the memory’s strategy is no longer declared on the space, for example right after the strategy is deleted.content (string) –
The memory text.
systemMetadata (dict) –
Provenance for the memory: the owning actor and session, and when it was created and last updated. Always present.
updatedAtequalscreatedAtfor a memory that has never been updated.actorId (string) –
The owning actor. Absent when none was recorded.
sessionId (string) –
The owning session. Absent when none was recorded.
createdAt (datetime) –
When the record was created. Always present on
ListMemoriesandGetMemory. It can be absent from search results.updatedAt (datetime) –
When the record was last updated. Equals
createdAtfor a record that has never been updated, and always for aSearchEventsresult.
metadata (dict) –
The memory’s metadata tags. All values are strings. May be empty.
(string) –
A metadata key: letters, digits, hyphens (
-), and underscores (_). Dots are not allowed, because a query uses dots to separate nested field names.(string) –
The value of a metadata entry.
Exceptions
OpenSearchMemory.Client.exceptions.ConflictExceptionOpenSearchMemory.Client.exceptions.ResourceNotFoundExceptionOpenSearchMemory.Client.exceptions.AccessDeniedExceptionOpenSearchMemory.Client.exceptions.ThrottlingExceptionOpenSearchMemory.Client.exceptions.InternalServerExceptionOpenSearchMemory.Client.exceptions.ValidationException