Skip to content

invoke_assistant async

invoke_assistant(
    message: MessageInput,
    *,
    config_overrides: Optional[AsyncIoTSiteWiseClientConfig] = None,
    conversation_id: Optional[ConversationId] = None,
    enable_trace: Optional[bool] = None,
) -> AsyncGenerator[InvokeAssistantResponse]

Invokes SiteWise Assistant to start or continue a conversation.

Parameters:

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

    The ID assigned to a conversation. IoT SiteWise automatically generates a unique ID for you, and this parameter is never required. However, if you prefer to have your own ID, you must specify it here in UUID format. If you specify your own ID, it must be globally unique.

  • message (MessageInput) –

    A text message sent to the SiteWise Assistant by the user.

  • enable_trace (Optional[bool], default: None ) –

    Specifies if to turn trace on or not. It is used to track the SiteWise Assistant's reasoning, and data access process.

Raises:

  • AccessDeniedException –

    Access is denied.

  • ConflictingOperationException –

    Your request has conflicting operations. This can occur if you're trying to perform more than one operation on the same resource at the same time.

  • InternalFailureException –

    IoT SiteWise can't process your request right now. Try again later.

  • InvalidRequestException –

    The request isn't valid. This can occur if your request contains malformed JSON or unsupported characters. Check your request and try again.

  • LimitExceededException –

    You've reached the quota for a resource. For example, this can occur if you're trying to associate more than the allowed number of child assets or attempting to create more than the allowed number of properties for an asset model.

    For more information, see Quotas in the IoT SiteWise User Guide.

  • ResourceNotFoundException –

    The requested resource can't be found.

  • ThrottlingException –

    Your request exceeded a rate limit. For example, you might have exceeded the number of IoT SiteWise assets that can be created per second, the allowed number of messages per second, and so on.

    For more information, see Quotas in the IoT SiteWise User Guide.

  • UnknownServiceError –

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

Source code in docs_src/capo_iotsitewise/_services/async_io_t_site_wise.py
@asynccontextmanager
async def invoke_assistant(
    self,
    message: "capo_iotsitewise.types.message_input.MessageInput",
    *,
    config_overrides: Optional[AsyncIoTSiteWiseClientConfig] = None,
    conversation_id: Optional[
        "capo_iotsitewise.types.conversation_id.ConversationId"
    ] = None,
    enable_trace: Optional[bool] = None,
) -> "AsyncGenerator[capo_iotsitewise.types.invoke_assistant_response.InvokeAssistantResponse]":
    """<p>Invokes SiteWise Assistant to start or continue a conversation.</p>

    Args:
        conversation_id: <p>The ID assigned to a conversation. IoT SiteWise automatically generates a unique ID for you, and this parameter is never required. However, if you prefer to have your own ID, you must specify it here in UUID format. If you specify your own ID, it must be globally unique.</p>
        message: <p>A text message sent to the SiteWise Assistant by the user.</p>
        enable_trace: <p>Specifies if to turn trace on or not. It is used to track the SiteWise Assistant's reasoning, and data access process.</p>

    Raises:
        capo_iotsitewise.errors.access_denied_exception.AccessDeniedException: <p>Access is denied.</p>
        capo_iotsitewise.errors.conflicting_operation_exception.ConflictingOperationException: <p>Your request has conflicting operations. This can occur if you're trying to perform more than one operation on the same resource at the same time.</p>
        capo_iotsitewise.errors.internal_failure_exception.InternalFailureException: <p>IoT SiteWise can't process your request right now. Try again later.</p>
        capo_iotsitewise.errors.invalid_request_exception.InvalidRequestException: <p>The request isn't valid. This can occur if your request contains malformed JSON or unsupported characters. Check your request and try again.</p>
        capo_iotsitewise.errors.limit_exceeded_exception.LimitExceededException: <p>You've reached the quota for a resource. For example, this can occur if you're trying to associate more than the allowed number of child assets or attempting to create more than the allowed number of properties for an asset model.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/iot-sitewise/latest/userguide/quotas.html">Quotas</a> in the <i>IoT SiteWise User Guide</i>.</p>
        capo_iotsitewise.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource can't be found.</p>
        capo_iotsitewise.errors.throttling_exception.ThrottlingException: <p>Your request exceeded a rate limit. For example, you might have exceeded the number of IoT SiteWise assets that can be created per second, the allowed number of messages per second, and so on.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/iot-sitewise/latest/userguide/quotas.html">Quotas</a> in the <i>IoT SiteWise User Guide</i>.</p>
        capo_iotsitewise.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_iotsitewise.types.invoke_assistant_request.InvokeAssistantRequest]",
    ) -> AsyncOperationResponse[
        "capo_iotsitewise.types.invoke_assistant_response.InvokeAssistantResponse"
    ]:
        import capo_iotsitewise._operations.aws_io_t_site_wise.invoke_assistant

        (
            output,
            http_response,
        ) = await capo_iotsitewise._operations.aws_io_t_site_wise.invoke_assistant.async_invoke_assistant(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_iotsitewise.types.invoke_assistant_request.InvokeAssistantRequest",
    ) -> dict[str, Any]:
        import capo_iotsitewise.types.invoke_assistant_request

        return capo_iotsitewise.types.invoke_assistant_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_iotsitewise.types.invoke_assistant_response.InvokeAssistantResponse",
    ) -> dict[str, Any]:
        import capo_iotsitewise.types.invoke_assistant_response

        return capo_iotsitewise.types.invoke_assistant_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "InvokeAssistant",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_iotsitewise.types.invoke_assistant_request.InvokeAssistantRequest = {
        "message": message
    }
    if conversation_id is not None:
        input_["conversation_id"] = conversation_id
    if enable_trace is not None:
        input_["enable_trace"] = enable_trace

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