OpenSearchMemory / Client / batch_get_event

batch_get_event

OpenSearchMemory.Client.batch_get_event(**kwargs)

Gets up to 10 events by ID, each as GetEvent returns it, including its payload.

If you supply actorId or sessionId, every requested event must match it. Each event has its own outcome. The operation reports an event that it can’t return in errors instead of failing, with an error code named for the exception that GetEvent would return for it. The operation reports both an event that doesn’t exist and an event outside the supplied scope as RESOURCE_NOT_FOUND.

The exception is the space’s customer managed AWS KMS key: if it is disabled, pending deletion, can’t be used for decryption, or was deleted, the whole call fails with ValidationException, as GetEvent does.

See also: AWS API Documentation

Request Syntax

response = client.batch_get_event(
    spaceId='string',
    actorId='string',
    sessionId='string',
    eventIds=[
        'string',
    ]
)
Parameters:
  • spaceId (string) –

    [REQUIRED]

    The ID of the space.

  • actorId (string) – The actor that every requested event must belong to. Omit it to skip this check. The operation reports an event that doesn’t match in errors as RESOURCE_NOT_FOUND.

  • sessionId (string) – The session that every requested event must belong to. Omit it to skip this check. The operation reports an event that doesn’t match in errors as RESOURCE_NOT_FOUND.

  • eventIds (list) –

    [REQUIRED]

    The IDs of the events to get: 1 to 10, without duplicates.

    • (string) –

      An event ID, assigned by the service.

Return type:

dict

Returns:

Response Syntax

{
    'events': [
        {
            'eventId': 'string',
            'spaceId': 'string',
            'actorId': 'string',
            'sessionId': 'string',
            'payload': {
                'conversational': {
                    'unified': {
                        'source': {
                            'object': {
                                'messages': [
                                    {
                                        'role': 'USER'|'ASSISTANT'|'SYSTEM',
                                        'content': {
                                            'text': 'string'
                                        }
                                    },
                                ]
                            }
                        }
                    }
                },
                'structuredData': {
                    'source': {
                        'json': {...}|[...]|123|123.4|'string'|True|None
                    }
                },
                'blob': {
                    'contentType': 'application/pdf'|'image/png'|'image/jpeg',
                    'source': {
                        's3Location': {
                            'uri': 'string'
                        }
                    }
                }
            },
            'metadata': {
                'string': 'string'
            },
            'eventTimestamp': datetime(2015, 1, 1)
        },
    ],
    'errors': [
        {
            'eventId': 'string',
            'errorCode': 'RESOURCE_NOT_FOUND'|'THROTTLING'|'ACCESS_DENIED'|'INTERNAL_SERVER',
            'message': 'string'
        },
    ]
}

Response Structure

  • (dict) –

    • events (list) –

      The events found, in the order that you requested their IDs.

      • (dict) –

        An event, including its payload.

        • eventId (string) –

          The event’s ID.

        • spaceId (string) –

          The ID of the space.

        • actorId (string) –

          The ID of the actor the event belongs to.

        • sessionId (string) –

          The ID of the session the event belongs to.

        • payload (dict) –

          The event’s content, as submitted to CreateEvent.

          Note

          This is a Tagged Union structure. Only one of the following top level keys will be set: conversational, structuredData, blob. If a client receives an unknown member it will set SDK_UNKNOWN_MEMBER as the top level key, which maps to the name or tag of the unknown member. The structure of SDK_UNKNOWN_MEMBER is as follows:

          'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
          
          • conversational (dict) –

            Conversation turns.

            Note

            This is a Tagged Union structure. Only one of the following top level keys will be set: unified. If a client receives an unknown member it will set SDK_UNKNOWN_MEMBER as the top level key, which maps to the name or tag of the unknown member. The structure of SDK_UNKNOWN_MEMBER is as follows:

            'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
            
            • unified (dict) –

              Conversation turns in the service’s own format.

              • source (dict) –

                The conversation.

                Note

                This is a Tagged Union structure. Only one of the following top level keys will be set: object. If a client receives an unknown member it will set SDK_UNKNOWN_MEMBER as the top level key, which maps to the name or tag of the unknown member. The structure of SDK_UNKNOWN_MEMBER is as follows:

                'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
                
                • object (dict) –

                  The conversation turns.

                  • messages (list) –

                    The conversation turns, in order. The order matters for extraction.

                    • (dict) –

                      A conversation turn.

                      • role (string) –

                        The author of the turn.

                      • content (dict) –

                        The content of the turn.

                        • text (string) –

                          The text of the turn.

          • structuredData (dict) –

            Structured (non-conversational) content, for example a deployment result that an agent should remember.

            • source (dict) –

              The structured content.

              Note

              This is a Tagged Union structure. Only one of the following top level keys will be set: json. If a client receives an unknown member it will set SDK_UNKNOWN_MEMBER as the top level key, which maps to the name or tag of the unknown member. The structure of SDK_UNKNOWN_MEMBER is as follows:

              'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
              
              • json (document) –

                The structured content, as a JSON object of at most 1 MiB when serialized as UTF-8, nested at most 10 levels deep.

          • blob (dict) –

            A document stored in Amazon S3, such as a PDF.

            • contentType (string) –

              The document’s media type. Only application/pdf is supported. Any other value fails with ValidationException.

            • source (dict) –

              The location of the document.

              Note

              This is a Tagged Union structure. Only one of the following top level keys will be set: s3Location. If a client receives an unknown member it will set SDK_UNKNOWN_MEMBER as the top level key, which maps to the name or tag of the unknown member. The structure of SDK_UNKNOWN_MEMBER is as follows:

              'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
              
              • s3Location (dict) –

                The S3 object holding the document.

                • uri (string) –

                  The object’s S3 URI, for example s3://bucket/key. The bucket must be in the space’s Region. You need s3:GetObject on the object, and kms:Decrypt on its key if the object uses SSE-KMS. The event doesn’t store the object itself.

        • metadata (dict) –

          The event’s metadata tags, as supplied to CreateEvent. 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.

        • eventTimestamp (datetime) –

          The time the event occurred.

    • errors (list) –

      An entry for each requested event that the call didn’t return. Empty when the call returned every event.

      • (dict) –

        A requested event that the call didn’t return, and the reason.

        • eventId (string) –

          The ID of the requested event.

        • errorCode (string) –

          The reason that the call didn’t return the event.

        • message (string) –

          A human-readable description.

Exceptions

  • OpenSearchMemory.Client.exceptions.ResourceNotFoundException

  • OpenSearchMemory.Client.exceptions.AccessDeniedException

  • OpenSearchMemory.Client.exceptions.ThrottlingException

  • OpenSearchMemory.Client.exceptions.InternalServerException

  • OpenSearchMemory.Client.exceptions.ValidationException