Skip to content

get_recommendations async

get_recommendations(
    assistant_id: UuidOrArn,
    session_id: UuidOrArn,
    *,
    config_overrides: Optional[AsyncWisdomClientConfig] = None,
    max_results: Optional[MaxResults] = None,
    wait_time_seconds: Optional[WaitTimeSeconds] = None,
) -> GetRecommendationsResponse

Retrieves recommendations for the specified session. To avoid retrieving the same recommendations in subsequent calls, use NotifyRecommendationsReceived. This API supports long-polling behavior with the waitTimeSeconds parameter. Short poll is the default behavior and only returns recommendations already available. To perform a manual query against an assistant, use QueryAssistant.

Parameters:

  • assistant_id (UuidOrArn) –

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

  • session_id (UuidOrArn) –

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

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

    The maximum number of results to return per page.

  • wait_time_seconds (Optional[WaitTimeSeconds], default: None ) –

    The duration (in seconds) for which the call waits for a recommendation to be made available before returning. If a recommendation is available, the call returns sooner than WaitTimeSeconds. If no messages are available and the wait time expires, the call returns successfully with an empty list.

Raises:

Source code in docs_src/capo_wisdom/_services/async_wisdom.py
async def get_recommendations(
    self,
    assistant_id: "capo_wisdom.types.uuid_or_arn.UuidOrArn",
    session_id: "capo_wisdom.types.uuid_or_arn.UuidOrArn",
    *,
    config_overrides: Optional[AsyncWisdomClientConfig] = None,
    max_results: Optional["capo_wisdom.types.max_results.MaxResults"] = None,
    wait_time_seconds: Optional[
        "capo_wisdom.types.wait_time_seconds.WaitTimeSeconds"
    ] = None,
) -> "capo_wisdom.types.get_recommendations_response.GetRecommendationsResponse":
    """<p>Retrieves recommendations for the specified session. To avoid retrieving the same recommendations in subsequent calls, use <a href="https://docs.aws.amazon.com/wisdom/latest/APIReference/API_NotifyRecommendationsReceived.html">NotifyRecommendationsReceived</a>. This API supports long-polling behavior with the <code>waitTimeSeconds</code> parameter. Short poll is the default behavior and only returns recommendations already available. To perform a manual query against an assistant, use <a href="https://docs.aws.amazon.com/wisdom/latest/APIReference/API_QueryAssistant.html">QueryAssistant</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>
        session_id: <p>The identifier of the session. Can be either the ID or the ARN. URLs cannot contain the ARN.</p>
        max_results: <p>The maximum number of results to return per page.</p>
        wait_time_seconds: <p>The duration (in seconds) for which the call waits for a recommendation to be made available before returning. If a recommendation is available, the call returns sooner than <code>WaitTimeSeconds</code>. If no messages are available and the wait time expires, the call returns successfully with an empty list.</p>

    Raises:
        capo_wisdom.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</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.get_recommendations_request.GetRecommendationsRequest]",
    ) -> AsyncOperationResponse[
        "capo_wisdom.types.get_recommendations_response.GetRecommendationsResponse"
    ]:
        import capo_wisdom._operations.wisdom_service.get_recommendations

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

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

        return capo_wisdom.types.get_recommendations_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("GetRecommendations", redact_output=_redact_output),
    )
    input_: capo_wisdom.types.get_recommendations_request.GetRecommendationsRequest = {
        "assistant_id": assistant_id,
        "session_id": session_id,
    }
    if max_results is not None:
        input_["max_results"] = max_results
    if wait_time_seconds is not None:
        input_["wait_time_seconds"] = wait_time_seconds

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