Skip to content

chat

Operation

Async only

This operation uses an event stream, so only the asynchronous client supports it.

chat async

chat(request: ChatInput | ChatInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[ChatInputDict]) -> AsyncDuplexEventStream[ChatInputStream, ChatOutputStream, ChatOutput]

Starts or continues a streaming Amazon Q Business conversation.

Parameters:

Name Type Description Default
request ChatInput | ChatInputDict | None

The input as a model or dictionary. Pass this or keyword arguments, not both.

None
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None
**kwargs Unpack[ChatInputDict]

The input fields as keyword arguments.

{}

Returns:

Type Description
AsyncDuplexEventStream[ChatInputStream, ChatOutputStream, ChatOutput]

An AsyncDuplexEventStream for bidirectional streaming.

Input

Pass the input as keyword arguments, a positional dictionary, or a positional model object. Pass plugins separately as a keyword argument.

ChatInputDict

Bases: TypedDict

Dictionary form of ChatInput.

Attributes

application_id instance-attribute
application_id: Required[str]

The identifier of the Amazon Q Business application linked to a streaming Amazon Q Business conversation.

client_token instance-attribute
client_token: str | None

A token that you provide to identify the chat input.

This field is autopopulated if not provided.

conversation_id instance-attribute
conversation_id: str | None

The identifier of the Amazon Q Business conversation.

parent_message_id instance-attribute
parent_message_id: str | None

The identifier used to associate a user message with a AI generated response.

user_groups instance-attribute
user_groups: Sequence[str] | None

The group names that a user associated with the chat input belongs to.

user_id instance-attribute
user_id: str | None

The identifier of the user attached to the chat input.

ChatInput dataclass

Bases: _SerdeShape

Dataclass for ChatInput structure.

Attributes

application_id class-attribute instance-attribute
application_id: str | None = ...

The identifier of the Amazon Q Business application linked to a streaming Amazon Q Business conversation.

client_token class-attribute instance-attribute
client_token: str | None = ...

A token that you provide to identify the chat input.

This field is autopopulated if not provided.

conversation_id class-attribute instance-attribute
conversation_id: str | None = ...

The identifier of the Amazon Q Business conversation.

parent_message_id class-attribute instance-attribute
parent_message_id: str | None = ...

The identifier used to associate a user message with a AI generated response.

user_groups class-attribute instance-attribute
user_groups: list[str] | None = ...

The group names that a user associated with the chat input belongs to.

user_id class-attribute instance-attribute
user_id: str | None = ...

The identifier of the user attached to the chat input.

Output

This operation returns an AsyncDuplexEventStream for bidirectional streaming.

Event Stream Structure

Input Event Type

ChatInputStream

Output Event Type

ChatOutputStream

Initial Response Structure

ChatOutput dataclass

Bases: _SerdeShape

Dataclass for ChatOutput structure.

Attributes
response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.