Skip to content

chat_sync async

chat_sync(
    application_id: ApplicationId,
    *,
    config_overrides: Optional[AsyncQBusinessClientConfig] = None,
    user_id: Optional[UserId] = None,
    user_groups: Optional[UserGroups] = None,
    user_message: Optional[UserMessage] = None,
    attachments: Optional[AttachmentsInput] = None,
    action_execution: Optional[ActionExecution] = None,
    auth_challenge_response: Optional[AuthChallengeResponse] = None,
    conversation_id: Optional[ConversationId] = None,
    parent_message_id: Optional[MessageId] = None,
    attribute_filter: Optional[AttributeFilter] = None,
    chat_mode: Optional[ChatMode] = None,
    chat_mode_configuration: Optional[ChatModeConfiguration] = None,
    client_token: Optional[ClientToken] = None,
) -> ChatSyncOutput

Starts or continues a non-streaming Amazon Q Business conversation.

Parameters:

  • application_id (ApplicationId) –

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

  • user_id (Optional[UserId], default: None ) –

    The identifier of the user attached to the chat input.

  • user_groups (Optional[UserGroups], default: None ) –

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

  • user_message (Optional[UserMessage], default: None ) –

    A end user message in a conversation.

  • attachments (Optional[AttachmentsInput], default: None ) –

    A list of files uploaded directly during chat. You can upload a maximum of 5 files of upto 10 MB each.

  • action_execution (Optional[ActionExecution], default: None ) –

    A request from an end user to perform an Amazon Q Business plugin action.

  • auth_challenge_response (Optional[AuthChallengeResponse], default: None ) –

    An authentication verification event response by a third party authentication server to Amazon Q Business.

  • conversation_id (Optional[ConversationId], default: None ) –

    The identifier of the Amazon Q Business conversation.

  • parent_message_id (Optional[MessageId], default: None ) –

    The identifier of the previous system message in a conversation.

  • attribute_filter (Optional[AttributeFilter], default: None ) –

    Enables filtering of Amazon Q Business web experience responses based on document attributes or metadata fields.

  • chat_mode (Optional[ChatMode], default: None ) –

    The chatMode parameter determines the chat modes available to Amazon Q Business users:

    • RETRIEVAL_MODE - If you choose this mode, Amazon Q generates responses solely from the data sources connected and indexed by the application. If an answer is not found in the data sources or there are no data sources available, Amazon Q will respond with a "No Answer Found" message, unless LLM knowledge has been enabled. In that case, Amazon Q will generate a response from the LLM knowledge

    • CREATOR_MODE - By selecting this mode, you can choose to generate responses only from the LLM knowledge. You can also attach files and have Amazon Q generate a response based on the data in those files. If the attached files do not contain an answer for the query, Amazon Q will automatically fall back to generating a response from the LLM knowledge.

    • PLUGIN_MODE - By selecting this mode, users can choose to use plugins in chat to get their responses.

    If none of the modes are selected, Amazon Q will only respond using the information from the attached files.

    For more information, see Admin controls and guardrails, Plugins, and Response sources.

  • chat_mode_configuration (Optional[ChatModeConfiguration], default: None ) –

    The chat mode configuration for an Amazon Q Business application.

  • client_token (Optional[ClientToken], default: None ) –

    A token that you provide to identify a chat request.

Raises:

  • AccessDeniedException –

    You don't have access to perform this action. Make sure you have the required permission policies and user accounts and try again.

  • ConflictException –

    You are trying to perform an action that conflicts with the current status of your resource. Fix any inconsistencies with your resources and try again.

  • ExternalResourceException –

    An external resource that you configured with your application is returning errors and preventing this operation from succeeding. Fix those errors and try again.

  • InternalServerException –

    An issue occurred with the internal server used for your Amazon Q Business service. Wait some minutes and try again, or contact Support for help.

  • LicenseNotFoundException –

    You don't have permissions to perform the action because your license is inactive. Ask your admin to activate your license and try again after your licence is active.

  • ResourceNotFoundException –

    The application or plugin resource you want to use doesn’t exist. Make sure you have provided the correct resource and try again.

  • ThrottlingException –

    The request was denied due to throttling. Reduce the number of requests and try again.

  • ValidationException –

    The input doesn't meet the constraints set by the Amazon Q Business service. Provide the correct input and try again.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_qbusiness/_services/async_q_business.py
async def chat_sync(
    self,
    application_id: "capo_qbusiness.types.application_id.ApplicationId",
    *,
    config_overrides: Optional[AsyncQBusinessClientConfig] = None,
    user_id: Optional["capo_qbusiness.types.user_id.UserId"] = None,
    user_groups: Optional["capo_qbusiness.types.user_groups.UserGroups"] = None,
    user_message: Optional["capo_qbusiness.types.user_message.UserMessage"] = None,
    attachments: Optional[
        "capo_qbusiness.types.attachments_input.AttachmentsInput"
    ] = None,
    action_execution: Optional[
        "capo_qbusiness.types.action_execution.ActionExecution"
    ] = None,
    auth_challenge_response: Optional[
        "capo_qbusiness.types.auth_challenge_response.AuthChallengeResponse"
    ] = None,
    conversation_id: Optional[
        "capo_qbusiness.types.conversation_id.ConversationId"
    ] = None,
    parent_message_id: Optional["capo_qbusiness.types.message_id.MessageId"] = None,
    attribute_filter: Optional[
        "capo_qbusiness.types.attribute_filter.AttributeFilter"
    ] = None,
    chat_mode: Optional["capo_qbusiness.types.chat_mode.ChatMode"] = None,
    chat_mode_configuration: Optional[
        "capo_qbusiness.types.chat_mode_configuration.ChatModeConfiguration"
    ] = None,
    client_token: Optional["capo_qbusiness.types.client_token.ClientToken"] = None,
) -> "capo_qbusiness.types.chat_sync_output.ChatSyncOutput":
    """<p>Starts or continues a non-streaming Amazon Q Business conversation.</p>

    Args:
        application_id: <p>The identifier of the Amazon Q Business application linked to the Amazon Q Business conversation.</p>
        user_id: <p>The identifier of the user attached to the chat input.</p>
        user_groups: <p>The group names that a user associated with the chat input belongs to.</p>
        user_message: <p>A end user message in a conversation.</p>
        attachments: <p>A list of files uploaded directly during chat. You can upload a maximum of 5 files of upto 10 MB each.</p>
        action_execution: <p>A request from an end user to perform an Amazon Q Business plugin action.</p>
        auth_challenge_response: <p>An authentication verification event response by a third party authentication server to Amazon Q Business.</p>
        conversation_id: <p>The identifier of the Amazon Q Business conversation.</p>
        parent_message_id: <p>The identifier of the previous system message in a conversation.</p>
        attribute_filter: <p>Enables filtering of Amazon Q Business web experience responses based on document attributes or metadata fields.</p>
        chat_mode: <p>The <code>chatMode</code> parameter determines the chat modes available to Amazon Q Business users:</p> <ul> <li> <p> <code>RETRIEVAL_MODE</code> - If you choose this mode, Amazon Q generates responses solely from the data sources connected and indexed by the application. If an answer is not found in the data sources or there are no data sources available, Amazon Q will respond with a "<i>No Answer Found</i>" message, unless LLM knowledge has been enabled. In that case, Amazon Q will generate a response from the LLM knowledge</p> </li> <li> <p> <code>CREATOR_MODE</code> - By selecting this mode, you can choose to generate responses only from the LLM knowledge. You can also attach files and have Amazon Q generate a response based on the data in those files. If the attached files do not contain an answer for the query, Amazon Q will automatically fall back to generating a response from the LLM knowledge.</p> </li> <li> <p> <code>PLUGIN_MODE</code> - By selecting this mode, users can choose to use plugins in chat to get their responses.</p> </li> </ul> <note> <p>If none of the modes are selected, Amazon Q will only respond using the information from the attached files.</p> </note> <p>For more information, see <a href="https://docs.aws.amazon.com/amazonq/latest/qbusiness-ug/guardrails.html">Admin controls and guardrails</a>, <a href="https://docs.aws.amazon.com/amazonq/latest/qbusiness-ug/plugins.html">Plugins</a>, and <a href="https://docs.aws.amazon.com/amazonq/latest/business-use-dg/using-web-experience.html#chat-source-scope">Response sources</a>.</p>
        chat_mode_configuration: <p>The chat mode configuration for an Amazon Q Business application.</p>
        client_token: <p>A token that you provide to identify a chat request.</p>

    Raises:
        capo_qbusiness.errors.access_denied_exception.AccessDeniedException: <p> You don't have access to perform this action. Make sure you have the required permission policies and user accounts and try again.</p>
        capo_qbusiness.errors.conflict_exception.ConflictException: <p>You are trying to perform an action that conflicts with the current status of your resource. Fix any inconsistencies with your resources and try again.</p>
        capo_qbusiness.errors.external_resource_exception.ExternalResourceException: <p>An external resource that you configured with your application is returning errors and preventing this operation from succeeding. Fix those errors and try again. </p>
        capo_qbusiness.errors.internal_server_exception.InternalServerException: <p>An issue occurred with the internal server used for your Amazon Q Business service. Wait some minutes and try again, or contact <a href="http://aws.amazon.com/contact-us/">Support</a> for help.</p>
        capo_qbusiness.errors.license_not_found_exception.LicenseNotFoundException: <p>You don't have permissions to perform the action because your license is inactive. Ask your admin to activate your license and try again after your licence is active.</p>
        capo_qbusiness.errors.resource_not_found_exception.ResourceNotFoundException: <p>The application or plugin resource you want to use doesn’t exist. Make sure you have provided the correct resource and try again.</p>
        capo_qbusiness.errors.throttling_exception.ThrottlingException: <p>The request was denied due to throttling. Reduce the number of requests and try again.</p>
        capo_qbusiness.errors.validation_exception.ValidationException: <p>The input doesn't meet the constraints set by the Amazon Q Business service. Provide the correct input and try again.</p>
        capo_qbusiness.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_qbusiness.types.chat_sync_input.ChatSyncInput]",
    ) -> AsyncOperationResponse[
        "capo_qbusiness.types.chat_sync_output.ChatSyncOutput"
    ]:
        import capo_qbusiness._operations.expert_q.chat_sync

        (
            output,
            http_response,
        ) = await capo_qbusiness._operations.expert_q.chat_sync.async_chat_sync(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ChatSync")
    )
    input_: capo_qbusiness.types.chat_sync_input.ChatSyncInput = {
        "application_id": application_id
    }
    if user_id is not None:
        input_["user_id"] = user_id
    if user_groups is not None:
        input_["user_groups"] = user_groups
    if user_message is not None:
        input_["user_message"] = user_message
    if attachments is not None:
        input_["attachments"] = attachments
    if action_execution is not None:
        input_["action_execution"] = action_execution
    if auth_challenge_response is not None:
        input_["auth_challenge_response"] = auth_challenge_response
    if conversation_id is not None:
        input_["conversation_id"] = conversation_id
    if parent_message_id is not None:
        input_["parent_message_id"] = parent_message_id
    if attribute_filter is not None:
        input_["attribute_filter"] = attribute_filter
    if chat_mode is not None:
        input_["chat_mode"] = chat_mode
    if chat_mode_configuration is not None:
        input_["chat_mode_configuration"] = chat_mode_configuration
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output