Skip to content

query_assistant async

query_assistant(
    assistant_id: UuidOrArn,
    query_text: QueryText,
    *,
    config_overrides: Optional[AsyncWisdomClientConfig] = None,
    next_token: Optional[NextToken] = None,
    max_results: Optional[MaxResults] = None,
) -> QueryAssistantResponse

Performs a manual search against the specified assistant. To retrieve recommendations for an assistant, use GetRecommendations.

Parameters:

  • assistant_id (UuidOrArn) –

    The identifier of the Wisdom assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.

  • query_text (QueryText) –

    The text to search for.

  • next_token (Optional[NextToken], default: None ) –

    The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.

  • max_results (Optional[MaxResults], default: None ) –

    The maximum number of results to return per page.

Raises:

  • AccessDeniedException –

    You do not have sufficient access to perform this action.

  • RequestTimeoutException –

    The request reached the service more than 15 minutes after the date stamp on the request or more than 15 minutes after the request expiration date (such as for pre-signed URLs), or the date stamp on the request is more than 15 minutes in the future.

  • ResourceNotFoundException –

    The specified resource does not exist.

  • ValidationException –

    The input fails to satisfy the constraints specified by a service.

  • UnknownServiceError –

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

Source code in docs_src/capo_wisdom/_services/async_wisdom.py
async def query_assistant(
    self,
    assistant_id: "capo_wisdom.types.uuid_or_arn.UuidOrArn",
    query_text: "capo_wisdom.types.query_text.QueryText",
    *,
    config_overrides: Optional[AsyncWisdomClientConfig] = None,
    next_token: Optional["capo_wisdom.types.next_token.NextToken"] = None,
    max_results: Optional["capo_wisdom.types.max_results.MaxResults"] = None,
) -> "capo_wisdom.types.query_assistant_response.QueryAssistantResponse":
    """<p>Performs a manual search against the specified assistant. To retrieve recommendations for an assistant, use <a href="https://docs.aws.amazon.com/wisdom/latest/APIReference/API_GetRecommendations.html">GetRecommendations</a>. </p>

    Args:
        assistant_id: <p>The identifier of the Wisdom assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.</p>
        query_text: <p>The text to search for.</p>
        next_token: <p>The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.</p>
        max_results: <p>The maximum number of results to return per page.</p>

    Raises:
        capo_wisdom.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_wisdom.errors.request_timeout_exception.RequestTimeoutException: <p>The request reached the service more than 15 minutes after the date stamp on the request or more than 15 minutes after the request expiration date (such as for pre-signed URLs), or the date stamp on the request is more than 15 minutes in the future.</p>
        capo_wisdom.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
        capo_wisdom.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by a service.</p>
        capo_wisdom.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_wisdom.types.query_assistant_request.QueryAssistantRequest]",
    ) -> AsyncOperationResponse[
        "capo_wisdom.types.query_assistant_response.QueryAssistantResponse"
    ]:
        import capo_wisdom._operations.wisdom_service.query_assistant

        (
            output,
            http_response,
        ) = await capo_wisdom._operations.wisdom_service.query_assistant.async_query_assistant(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_wisdom.types.query_assistant_request.QueryAssistantRequest",
    ) -> dict[str, Any]:
        import capo_wisdom.types.query_assistant_request

        return capo_wisdom.types.query_assistant_request.redact_sensitive(input_)

    def _redact_output(
        output: "capo_wisdom.types.query_assistant_response.QueryAssistantResponse",
    ) -> dict[str, Any]:
        import capo_wisdom.types.query_assistant_response

        return capo_wisdom.types.query_assistant_response.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "QueryAssistant",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_wisdom.types.query_assistant_request.QueryAssistantRequest = {
        "assistant_id": assistant_id,
        "query_text": query_text,
    }
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results

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