Assurance / Client / chat

chat

Assurance.Client.chat(**kwargs)

Starts a streaming chat turn with the AWS Assurance agent. Returns an event stream of chat events, including chunks, tool calls, and errors.

See also: AWS API Documentation

Request Syntax

response = client.chat(
    message='string',
    sessionId='string',
    environmentArn='string',
    expectedSequenceNumber=123
)
Parameters:
  • message (string) –

    [REQUIRED]

    The chat message to send to the AWS Assurance agent.

  • sessionId (string) – The session to continue. Pass the sessionId returned by a previous Chat call to continue that session. If you omit it, AWS Assurance starts a new session. If the session doesn’t exist or has expired, the operation returns ResourceNotFoundException. If the format isn’t valid, the operation returns ValidationException.

  • environmentArn (string) –

    [REQUIRED]

    The ARN of this governance environment.

  • expectedSequenceNumber (integer) – The sequence number of the last message you received. If the service detects a more recent sequence number, the request fails with ConflictException, indicating a concurrent update.

Return type:

dict

Returns:

The response of this operation contains an EventStream member. When iterated the EventStream will yield events based on the structure below, where only one of the top level keys will be present for any given event.

Response Syntax

{
    'eventStream': EventStream({
        'chunk': {
            'message': 'string'
        },
        'toolCall': {
            'message': 'string',
            'eventDescription': 'string'
        },
        'response': {},
        'error': {
            'message': 'string'
        }
    }),
    'sessionId': 'string',
    'sequenceNumber': 123
}

Response Structure

  • (dict) –

    • eventStream (EventStream) –

      The stream of chat events returned by the agent.

      • chunk (dict) –

        A partial streamed text chunk of the assistant response.

        • message (string) –

          The chunk text content.

      • toolCall (dict) –

        An event indicating the agent invoked a tool.

        • message (string) –

          The tool call message content.

        • eventDescription (string) –

          A human-readable description of the tool invocation.

      • response (dict) –

        An event marking the end of the assistant response. Receiving this event confirms that the stream completed successfully rather than being dropped.

      • error (dict) –

        An error event in the stream. The stream carries this event when an error occurs after the response has started; otherwise the operation returns a standard exception.

        • message (string) –

          The error message text.

    • sessionId (string) –

      The ID of the session. If you omitted sessionId in the request, use this value to continue the session in subsequent calls.

    • sequenceNumber (integer) –

      The updated sequence number for this session. Pass this value as expectedSequenceNumber on your next call.

Exceptions

  • Assurance.Client.exceptions.ServiceQuotaExceededException

  • Assurance.Client.exceptions.ConflictException

  • Assurance.Client.exceptions.ValidationException

  • Assurance.Client.exceptions.InternalServerException

  • Assurance.Client.exceptions.ThrottlingException

  • Assurance.Client.exceptions.AccessDeniedException

  • Assurance.Client.exceptions.ResourceNotFoundException