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 content or metadata, or it fails with ValidationException. Supplying content re-embeds the memory. A change to metadata alone doesn’t.

The memory keeps its memoryId across updates. Shortly after an update, searches stop returning the previous content.

memoryType can’t be changed. To change it, delete the memory and create a new one.

A memory past its expiry (set from the space’s memoryExpiryDays when the memory is written) reads as not found: the operation fails with ResourceNotFoundException and 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 content and the request would exceed the service’s rate for embedding requests, it fails with ThrottlingException. 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 AccessDeniedException if you aren’t allowed to use the key, and with ThrottlingException if AWS KMS throttles the request. It fails with ValidationException if 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 metadataMode to MERGE to keep the keys you don’t supply. Limits apply to the resulting metadata, not to the request. Keys that begin with x-amz- and the key documentS3Source are reserved: a request that sets one fails with ValidationException.

    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 metadata combines with what is stored. The default is REPLACE.

  • 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 GetMemory returns.

      • 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. updatedAt equals createdAt for 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 ListMemories and GetMemory. It can be absent from search results.

        • updatedAt (datetime) –

          When the record was last updated. Equals createdAt for a record that has never been updated, and always for a SearchEvents result.

      • 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