OpenSearchMemory / Client / create_memory

create_memory

OpenSearchMemory.Client.create_memory(**kwargs)

Writes a memory that you have already formed, without extracting it from events. The service embeds the text as given and stores it as a memory of the named strategy. To have the service extract memories from conversation turns, use CreateEvent instead.

The operation returns before the memory is searchable. The returned memoryId is final, but until the memory is indexed, GetMemory, UpdateMemory, and DeleteMemory return ResourceNotFoundException for it.

If 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.create_memory(
    spaceId='string',
    name='string',
    content='string',
    actorId='string',
    sessionId='string',
    metadata={
        'string': 'string'
    },
    clientToken='string'
)
Parameters:
  • spaceId (string) –

    [REQUIRED]

    The ID of the space that owns the memory, for example sp-02864597b164.

  • name (string) –

    [REQUIRED]

    The name of the strategy that the memory belongs to. The space must already declare the strategy, and the memory’s type comes from that strategy. The name must be 1 to 64 characters: letters, digits, periods, hyphens, and underscores, starting with a letter or digit.

  • content (string) –

    [REQUIRED]

    The memory text, stored and embedded as provided.

  • actorId (string) –

    [REQUIRED]

    The actor (end user or agent) that owns the memory.

  • sessionId (string) – The session that the memory belongs to. If you omit it, the service generates a session ID and returns it.

  • metadata (dict) –

    Metadata tags to store with the memory. Keys that begin with x-amz-, the key documentS3Source, and other keys that the service uses internally are reserved: a request that sets one fails with ValidationException, and the message names the key.

    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.

  • clientToken (string) –

    A unique, case-sensitive identifier that makes the request idempotent. Within 2 hours of the first request, a retry with the same token returns the same memoryId instead of creating a second memory. Reusing the token with a different name, content, metadata, actorId, or sessionId fails with ConflictException. If you omit sessionId, a retry with the same token gets the same session. If you omit the token, each call creates a new memory.

    This field is autopopulated if not provided.

Return type:

dict

Returns:

Response Syntax

{
    'memory': {
        'memoryId': 'string',
        'spaceId': 'string',
        'name': 'string',
        'actorId': 'string',
        'sessionId': 'string'
    }
}

Response Structure

  • (dict) –

    The acknowledged memory. It isn’t searchable yet when the call returns.

    • memory (dict) –

      The memory, identified but not yet indexed.

      • memoryId (string) –

        The final ID of the memory. Until the memory is indexed, GetMemory, UpdateMemory, and DeleteMemory return ResourceNotFoundException for it.

      • spaceId (string) –

        The ID of the space.

      • name (string) –

        The name of the strategy the memory belongs to.

      • actorId (string) –

        The ID of the actor the memory belongs to.

      • sessionId (string) –

        The ID of the session the memory belongs to, including one the service generated.

Exceptions