Skip to content

Commit a68c999

Browse files
author
awstools
committed
feat(client-personalize-runtime): This release adds support for a Reason attribute for predicted items generated by User-Personalization-v2.
1 parent 044d712 commit a68c999

File tree

5 files changed

+89
-2
lines changed

5 files changed

+89
-2
lines changed

clients/client-personalize-runtime/src/commands/GetPersonalizedRankingCommand.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
GetPersonalizedRankingRequest,
1010
GetPersonalizedRankingRequestFilterSensitiveLog,
1111
GetPersonalizedRankingResponse,
12+
GetPersonalizedRankingResponseFilterSensitiveLog,
1213
} from "../models/models_0";
1314
import {
1415
PersonalizeRuntimeClientResolvedConfig,
@@ -77,6 +78,9 @@ export interface GetPersonalizedRankingCommandOutput extends GetPersonalizedRank
7778
* // metadata: { // Metadata
7879
* // "<keys>": "STRING_VALUE",
7980
* // },
81+
* // reason: [ // ReasonList
82+
* // "STRING_VALUE",
83+
* // ],
8084
* // },
8185
* // ],
8286
* // recommendationId: "STRING_VALUE",
@@ -120,7 +124,7 @@ export class GetPersonalizedRankingCommand extends $Command
120124
})
121125
.s("AmazonPersonalizeRuntime", "GetPersonalizedRanking", {})
122126
.n("PersonalizeRuntimeClient", "GetPersonalizedRankingCommand")
123-
.f(GetPersonalizedRankingRequestFilterSensitiveLog, void 0)
127+
.f(GetPersonalizedRankingRequestFilterSensitiveLog, GetPersonalizedRankingResponseFilterSensitiveLog)
124128
.ser(se_GetPersonalizedRankingCommand)
125129
.de(de_GetPersonalizedRankingCommand)
126130
.build() {}

clients/client-personalize-runtime/src/commands/GetRecommendationsCommand.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
GetRecommendationsRequest,
1010
GetRecommendationsRequestFilterSensitiveLog,
1111
GetRecommendationsResponse,
12+
GetRecommendationsResponseFilterSensitiveLog,
1213
} from "../models/models_0";
1314
import {
1415
PersonalizeRuntimeClientResolvedConfig,
@@ -99,6 +100,9 @@ export interface GetRecommendationsCommandOutput extends GetRecommendationsRespo
99100
* // metadata: { // Metadata
100101
* // "<keys>": "STRING_VALUE",
101102
* // },
103+
* // reason: [ // ReasonList
104+
* // "STRING_VALUE",
105+
* // ],
102106
* // },
103107
* // ],
104108
* // recommendationId: "STRING_VALUE",
@@ -142,7 +146,7 @@ export class GetRecommendationsCommand extends $Command
142146
})
143147
.s("AmazonPersonalizeRuntime", "GetRecommendations", {})
144148
.n("PersonalizeRuntimeClient", "GetRecommendationsCommand")
145-
.f(GetRecommendationsRequestFilterSensitiveLog, void 0)
149+
.f(GetRecommendationsRequestFilterSensitiveLog, GetRecommendationsResponseFilterSensitiveLog)
146150
.ser(se_GetRecommendationsCommand)
147151
.de(de_GetRecommendationsCommand)
148152
.build() {}

clients/client-personalize-runtime/src/models/models_0.ts

+52
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,32 @@ export interface PredictedItem {
228228
* @public
229229
*/
230230
metadata?: Record<string, string>;
231+
232+
/**
233+
* <p>If you use User-Personalization-v2, a list of reasons for why the item was included in recommendations. Possible reasons include the following:</p>
234+
* <ul>
235+
* <li>
236+
* <p>Promoted item - Indicates the item was included as part of a promotion that you applied in your recommendation request.</p>
237+
* </li>
238+
* <li>
239+
* <p>Exploration - Indicates the item was included with exploration.
240+
* With exploration, recommendations include items with less interactions data or relevance for the user.
241+
* For more information about exploration, see
242+
* <a href="https://docs.aws.amazon.com/personalize/latest/dg/use-case-recipe-features.html#about-exploration">Exploration</a>.</p>
243+
* </li>
244+
* <li>
245+
* <p>
246+
* Popular item - Indicates the item was included as a placeholder popular item.
247+
* If you use a filter, depending on how many recommendations the filter removes,
248+
* Amazon Personalize might add placeholder items to meet the <code>numResults</code> for your
249+
* recommendation request. These items are popular items, based on interactions data, that satisfy your filter criteria.
250+
* They don't have a relevance score for the user.
251+
* </p>
252+
* </li>
253+
* </ul>
254+
* @public
255+
*/
256+
reason?: string[];
231257
}
232258

233259
/**
@@ -411,6 +437,24 @@ export const GetPersonalizedRankingRequestFilterSensitiveLog = (obj: GetPersonal
411437
...(obj.filterValues && { filterValues: SENSITIVE_STRING }),
412438
});
413439

440+
/**
441+
* @internal
442+
*/
443+
export const PredictedItemFilterSensitiveLog = (obj: PredictedItem): any => ({
444+
...obj,
445+
...(obj.metadata && { metadata: SENSITIVE_STRING }),
446+
});
447+
448+
/**
449+
* @internal
450+
*/
451+
export const GetPersonalizedRankingResponseFilterSensitiveLog = (obj: GetPersonalizedRankingResponse): any => ({
452+
...obj,
453+
...(obj.personalizedRanking && {
454+
personalizedRanking: obj.personalizedRanking.map((item) => PredictedItemFilterSensitiveLog(item)),
455+
}),
456+
});
457+
414458
/**
415459
* @internal
416460
*/
@@ -428,3 +472,11 @@ export const GetRecommendationsRequestFilterSensitiveLog = (obj: GetRecommendati
428472
...(obj.filterValues && { filterValues: SENSITIVE_STRING }),
429473
...(obj.promotions && { promotions: obj.promotions.map((item) => PromotionFilterSensitiveLog(item)) }),
430474
});
475+
476+
/**
477+
* @internal
478+
*/
479+
export const GetRecommendationsResponseFilterSensitiveLog = (obj: GetRecommendationsResponse): any => ({
480+
...obj,
481+
...(obj.itemList && { itemList: obj.itemList.map((item) => PredictedItemFilterSensitiveLog(item)) }),
482+
});

clients/client-personalize-runtime/src/protocols/Aws_restJson1.ts

+3
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,13 @@ const de_PredictedItem = (output: any, context: __SerdeContext): PredictedItem =
314314
itemId: __expectString,
315315
metadata: _json,
316316
promotionName: __expectString,
317+
reason: _json,
317318
score: __limitedParseDouble,
318319
}) as any;
319320
};
320321

322+
// de_ReasonList omitted.
323+
321324
const deserializeMetadata = (output: __HttpResponse): __ResponseMetadata => ({
322325
httpStatusCode: output.statusCode,
323326
requestId:

codegen/sdk-codegen/aws-models/personalize-runtime.json

+24
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,9 @@
11641164
},
11651165
"value": {
11661166
"target": "com.amazonaws.personalizeruntime#ColumnValue"
1167+
},
1168+
"traits": {
1169+
"smithy.api#sensitive": {}
11671170
}
11681171
},
11691172
"com.amazonaws.personalizeruntime#MetadataColumns": {
@@ -1255,6 +1258,12 @@
12551258
"traits": {
12561259
"smithy.api#documentation": "<p>Metadata about the item from your Items dataset.</p>"
12571260
}
1261+
},
1262+
"reason": {
1263+
"target": "com.amazonaws.personalizeruntime#ReasonList",
1264+
"traits": {
1265+
"smithy.api#documentation": "<p>If you use User-Personalization-v2, a list of reasons for why the item was included in recommendations. Possible reasons include the following:</p>\n <ul>\n <li>\n <p>Promoted item - Indicates the item was included as part of a promotion that you applied in your recommendation request.</p>\n </li>\n <li>\n <p>Exploration - Indicates the item was included with exploration.\n With exploration, recommendations include items with less interactions data or relevance for the user.\n For more information about exploration, see \n <a href=\"https://docs.aws.amazon.com/personalize/latest/dg/use-case-recipe-features.html#about-exploration\">Exploration</a>.</p>\n </li>\n <li>\n <p> \n Popular item - Indicates the item was included as a placeholder popular item.\n If you use a filter, depending on how many recommendations the filter removes, \n Amazon Personalize might add placeholder items to meet the <code>numResults</code> for your \n recommendation request. These items are popular items, based on interactions data, that satisfy your filter criteria.\n They don't have a relevance score for the user.\n </p>\n </li>\n </ul>"
1266+
}
12581267
}
12591268
},
12601269
"traits": {
@@ -1305,6 +1314,21 @@
13051314
}
13061315
}
13071316
},
1317+
"com.amazonaws.personalizeruntime#Reason": {
1318+
"type": "string",
1319+
"traits": {
1320+
"smithy.api#length": {
1321+
"min": 0,
1322+
"max": 256
1323+
}
1324+
}
1325+
},
1326+
"com.amazonaws.personalizeruntime#ReasonList": {
1327+
"type": "list",
1328+
"member": {
1329+
"target": "com.amazonaws.personalizeruntime#Reason"
1330+
}
1331+
},
13081332
"com.amazonaws.personalizeruntime#RecommendationID": {
13091333
"type": "string"
13101334
},

0 commit comments

Comments
 (0)