Skip to content

get_profile_recommendations async

get_profile_recommendations(
    domain_name: name,
    profile_id: uuid,
    recommender_name: name,
    *,
    config_overrides: Optional[AsyncCustomerProfilesClientConfig] = None,
    context: Optional[RecommenderContext] = None,
    recommender_filters: Optional[RecommenderFilters] = None,
    recommender_promotional_filters: Optional[RecommenderPromotionalFilters] = None,
    candidate_ids: Optional[CandidateIdList] = None,
    max_results: Optional[MaxSize500] = None,
    metadata_config: Optional[MetadataConfig] = None,
    diversity_config: Optional[RecommendationDiversityConfig] = None,
) -> GetProfileRecommendationsResponse

Fetches the recommendations for a profile in the input Customer Profiles domain. Fetches all the profile recommendations

Parameters:

  • domain_name (name) –

    The unique name of the domain.

  • profile_id (uuid) –

    The unique identifier of the profile for which to retrieve recommendations.

  • recommender_name (name) –

    The unique name of the recommender.

  • context (Optional[RecommenderContext], default: None ) –

    The contextual metadata used to provide dynamic runtime information to tailor recommendations.

  • recommender_filters (Optional[RecommenderFilters], default: None ) –

    A list of filters to apply to the returned recommendations. Filters define criteria for including or excluding items from the recommendation results.

  • recommender_promotional_filters (Optional[RecommenderPromotionalFilters], default: None ) –

    A list of promotional filters to apply to the recommendations. Promotional filters allow you to promote specific items within a configurable subset of recommendation results.

  • candidate_ids (Optional[CandidateIdList], default: None ) –

    A list of item IDs to rank for the user. Use this when you want to re-rank a specific set of items rather than getting recommendations from the full item catalog. Required for personalized-ranking use cases.

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

    The maximum number of recommendations to return. The default value is 10.

  • metadata_config (Optional[MetadataConfig], default: None ) –

    Configuration for including item metadata in the recommendation response. Use this to specify which metadata columns to return alongside recommended items.

  • diversity_config (Optional[RecommendationDiversityConfig], default: None ) –

    Runtime diversity configuration for this request. Enables diversity-aware recommendations and optionally supplies values for placeholder-based diversity caps configured on the recommender.

Raises:

Source code in docs_src/capo_customer_profiles/_services/async_customer_profiles.py
async def get_profile_recommendations(
    self,
    domain_name: "capo_customer_profiles.types.name.name",
    profile_id: "capo_customer_profiles.types.uuid.uuid",
    recommender_name: "capo_customer_profiles.types.name.name",
    *,
    config_overrides: Optional[AsyncCustomerProfilesClientConfig] = None,
    context: Optional[
        "capo_customer_profiles.types.recommender_context.RecommenderContext"
    ] = None,
    recommender_filters: Optional[
        "capo_customer_profiles.types.recommender_filters.RecommenderFilters"
    ] = None,
    recommender_promotional_filters: Optional[
        "capo_customer_profiles.types.recommender_promotional_filters.RecommenderPromotionalFilters"
    ] = None,
    candidate_ids: Optional[
        "capo_customer_profiles.types.candidate_id_list.CandidateIdList"
    ] = None,
    max_results: Optional[
        "capo_customer_profiles.types.max_size500.MaxSize500"
    ] = None,
    metadata_config: Optional[
        "capo_customer_profiles.types.metadata_config.MetadataConfig"
    ] = None,
    diversity_config: Optional[
        "capo_customer_profiles.types.recommendation_diversity_config.RecommendationDiversityConfig"
    ] = None,
) -> "capo_customer_profiles.types.get_profile_recommendations_response.GetProfileRecommendationsResponse":
    """<p>Fetches the recommendations for a profile in the input Customer Profiles domain. Fetches all the profile recommendations </p>

    Args:
        domain_name: <p>The unique name of the domain.</p>
        profile_id: <p>The unique identifier of the profile for which to retrieve recommendations.</p>
        recommender_name: <p>The unique name of the recommender.</p>
        context: <p>The contextual metadata used to provide dynamic runtime information to tailor recommendations.</p>
        recommender_filters: <p>A list of filters to apply to the returned recommendations. Filters define criteria for including or excluding items from the recommendation results.</p>
        recommender_promotional_filters: <p>A list of promotional filters to apply to the recommendations. Promotional filters allow you to promote specific items within a configurable subset of recommendation results.</p>
        candidate_ids: <p>A list of item IDs to rank for the user. Use this when you want to re-rank a specific set of items rather than getting recommendations from the full item catalog. Required for personalized-ranking use cases.</p>
        max_results: <p>The maximum number of recommendations to return. The default value is 10.</p>
        metadata_config: <p>Configuration for including item metadata in the recommendation response. Use this to specify which metadata columns to return alongside recommended items.</p>
        diversity_config: <p>Runtime diversity configuration for this request. Enables diversity-aware recommendations and optionally supplies values for placeholder-based diversity caps configured on the recommender.</p>

    Raises:
        capo_customer_profiles.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_customer_profiles.errors.bad_request_exception.BadRequestException: <p>The input you provided is invalid.</p>
        capo_customer_profiles.errors.internal_server_exception.InternalServerException: <p>An internal service error occurred.</p>
        capo_customer_profiles.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource does not exist, or access was denied.</p>
        capo_customer_profiles.errors.throttling_exception.ThrottlingException: <p>You exceeded the maximum number of requests.</p>
        capo_customer_profiles.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_customer_profiles.types.get_profile_recommendations_request.GetProfileRecommendationsRequest]",
    ) -> AsyncOperationResponse[
        "capo_customer_profiles.types.get_profile_recommendations_response.GetProfileRecommendationsResponse"
    ]:
        import capo_customer_profiles._operations.customer_profiles_20200815.get_profile_recommendations

        (
            output,
            http_response,
        ) = await capo_customer_profiles._operations.customer_profiles_20200815.get_profile_recommendations.async_get_profile_recommendations(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_customer_profiles.types.get_profile_recommendations_request.GetProfileRecommendationsRequest",
    ) -> dict[str, Any]:
        import capo_customer_profiles.types.get_profile_recommendations_request

        return capo_customer_profiles.types.get_profile_recommendations_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_customer_profiles.types.get_profile_recommendations_response.GetProfileRecommendationsResponse",
    ) -> dict[str, Any]:
        import capo_customer_profiles.types.get_profile_recommendations_response

        return capo_customer_profiles.types.get_profile_recommendations_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "GetProfileRecommendations",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_customer_profiles.types.get_profile_recommendations_request.GetProfileRecommendationsRequest = {
        "domain_name": domain_name,
        "profile_id": profile_id,
        "recommender_name": recommender_name,
    }
    if context is not None:
        input_["context"] = context
    if recommender_filters is not None:
        input_["recommender_filters"] = recommender_filters
    if recommender_promotional_filters is not None:
        input_["recommender_promotional_filters"] = recommender_promotional_filters
    if candidate_ids is not None:
        input_["candidate_ids"] = candidate_ids
    if max_results is not None:
        input_["max_results"] = max_results
    if metadata_config is not None:
        input_["metadata_config"] = metadata_config
    if diversity_config is not None:
        input_["diversity_config"] = diversity_config

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