Created
February 3, 2020 16:01
-
-
Save gcsfred/53cb78507d6504855e248215e5d4a5f2 to your computer and use it in GitHub Desktop.
Get product recommendations from Amazon Personalize (fragment)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_product_recommendations(config, user): | |
_log_info('Retrieving product recommendations') | |
return _get_recommendations(user, config['DEFAULT']['product_recommendations_campaignArn']) | |
def _get_recommendations(user, campaign): | |
personalize = boto3.client('personalize-runtime', 'us-east-2') | |
response = personalize.get_recommendations(campaignArn=campaign, userId=user) | |
answer = [] | |
_log_info('Recommended items:') | |
for item in response['itemList']: | |
item_id = item['itemId'] | |
answer.append(item_id) | |
_log_info('itemId:' + item_id) | |
return answer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment