OpenSearchMemory / Client / list_memories

list_memories

OpenSearchMemory.Client.list_memories(**kwargs)

Lists a space’s memories without a query, for example the most recent memories or the memories of one strategy. Filter by strategy and optionally by owning actor or session, sort by creation or update time, and page through the results. Results have no relevance score. To query or filter by metadata, use SearchMemories.

If memories are written or deleted while you page, the results can skip a memory or return it twice. You can page through only a limited number of results. A request past that limit fails with ValidationException (reason invalidNextToken), and the message gives the limit.

Memories past their expiry (set from the space’s memoryExpiryDays when each memory is written) are left out. Unlike SearchMemories, this operation also returns memories that consolidation has superseded.

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.list_memories(
    spaceId='string',
    memoryStrategies=[
        {
            'memoryType': 'SEMANTIC'|'SUMMARY'|'CUSTOM',
            'memoryStrategyNames': [
                'string',
            ]
        },
    ],
    actorIds=[
        'string',
    ],
    sessionIds=[
        'string',
    ],
    sortBy='CREATED_AT'|'UPDATED_AT',
    sortOrder='ASC'|'DESC',
    maxResults=123,
    nextToken='string'
)
Parameters:
  • spaceId (string) –

    [REQUIRED]

    The space whose memories to list.

  • memoryStrategies (list) –

    The strategies to list, as selectors. A selector without memoryStrategyNames lists every strategy of its type, and omitting memoryStrategies lists every strategy in the space. A name that is not a declared strategy of that type fails with ValidationException.

    • (dict) –

      A memory type and, optionally, specific strategy names of that type. A space can hold several strategies of the same type, so the type and its names are given together.

      • memoryType (string) – [REQUIRED]

        The memory type to search or list.

      • memoryStrategyNames (list) –

        Specific strategy names of memoryType. Omit it to include every strategy of that type.

        • (string) –

          The name of a strategy declared on a space, for example user-facts. Names are case-sensitive and must match the declared name exactly.

  • actorIds (list) –

    Lists only memories owned by one of these actors. Combined with sessionIds by AND: a memory must match both filters when both are given. Omit for no actor filter. An empty list fails validation. A memory stored without an actor never matches an actor filter.

    • (string) –

      The ID of an actor: the end user or agent that events and memories belong to.

  • sessionIds (list) –

    Lists only memories from one of these sessions. Combined with actorIds by AND. Omit for no session filter. An empty list fails validation. A memory stored without a session never matches a session filter.

    • (string) –

      The ID of a session, which groups an actor’s events.

  • sortBy (string) – The timestamp to sort by, as returned in systemMetadata: CREATED_AT (the default) or UPDATED_AT.

  • sortOrder (string) – The sort order: ASC or DESC. The default is DESC, most recent first.

  • maxResults (integer) – The maximum number of memories to return, from 1 to 100. The default is 20.

  • nextToken (string) – The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.

Return type:

dict

Returns:

Response Syntax

{
    'memories': [
        {
            'memoryId': 'string',
            'memoryType': 'SEMANTIC'|'SUMMARY'|'CUSTOM',
            'strategyName': 'string',
            'systemMetadata': {
                'actorId': 'string',
                'sessionId': 'string',
                'createdAt': datetime(2015, 1, 1),
                'updatedAt': datetime(2015, 1, 1)
            },
            'metadata': {
                'string': 'string'
            }
        },
    ],
    'nextToken': 'string'
}

Response Structure

  • (dict) –

    • memories (list) –

      The memories, in the requested order. Empty when there are none.

      • (dict) –

        A summary of a memory, as returned by ListMemories: its ID, type, provenance, and tags. It doesn’t include content. Call GetMemory for the full memory.

        • memoryId (string) –

          The memory’s ID, assigned by the service. IDs are opaque, can contain hyphens and underscores, and can be up to 512 characters long.

        • memoryType (string) –

          The memory type.

        • strategyName (string) –

          The name of the strategy the memory belongs to, for example user-facts: the strategy memoryStrategies selects on in ListMemories. Absent when the memory’s strategy is no longer declared on the space, for example right after the strategy is deleted.

        • systemMetadata (dict) –

          Provenance for the memory: the owning actor and session, and when it was created and last updated. Always present, with both timestamps.

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

          • (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.

    • nextToken (string) –

      The token for the next set of results. Absent when there are no more results.

Exceptions

  • OpenSearchMemory.Client.exceptions.ResourceNotFoundException

  • OpenSearchMemory.Client.exceptions.AccessDeniedException

  • OpenSearchMemory.Client.exceptions.ThrottlingException

  • OpenSearchMemory.Client.exceptions.InternalServerException

  • OpenSearchMemory.Client.exceptions.ValidationException