Skip to content

Commit 53b4df1

Browse files
author
awstools
committed
feat(client-wisdom): This release introduces a new API PutFeedback that allows submitting feedback to Wisdom on content relevance.
1 parent 0f250fe commit 53b4df1

File tree

7 files changed

+482
-0
lines changed

7 files changed

+482
-0
lines changed

clients/client-wisdom/src/Wisdom.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ import {
103103
NotifyRecommendationsReceivedCommandInput,
104104
NotifyRecommendationsReceivedCommandOutput,
105105
} from "./commands/NotifyRecommendationsReceivedCommand";
106+
import { PutFeedbackCommand, PutFeedbackCommandInput, PutFeedbackCommandOutput } from "./commands/PutFeedbackCommand";
106107
import {
107108
QueryAssistantCommand,
108109
QueryAssistantCommandInput,
@@ -879,6 +880,36 @@ export class Wisdom extends WisdomClient {
879880
}
880881
}
881882

883+
/**
884+
* <p>Submits feedback to Wisdom. The feedback is used to improve future recommendations from
885+
* <a href="https://docs.aws.amazon.com/wisdom/latest/APIReference/API_GetRecommendations.html">GetRecommendations</a> or
886+
* results from <a href="https://docs.aws.amazon.com/wisdom/latest/APIReference/API_QueryAssistant.html">QueryAssistant</a>.
887+
* Feedback can be resubmitted up to 6 hours after submission.
888+
* </p>
889+
*/
890+
public putFeedback(args: PutFeedbackCommandInput, options?: __HttpHandlerOptions): Promise<PutFeedbackCommandOutput>;
891+
public putFeedback(args: PutFeedbackCommandInput, cb: (err: any, data?: PutFeedbackCommandOutput) => void): void;
892+
public putFeedback(
893+
args: PutFeedbackCommandInput,
894+
options: __HttpHandlerOptions,
895+
cb: (err: any, data?: PutFeedbackCommandOutput) => void
896+
): void;
897+
public putFeedback(
898+
args: PutFeedbackCommandInput,
899+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: PutFeedbackCommandOutput) => void),
900+
cb?: (err: any, data?: PutFeedbackCommandOutput) => void
901+
): Promise<PutFeedbackCommandOutput> | void {
902+
const command = new PutFeedbackCommand(args);
903+
if (typeof optionsOrCb === "function") {
904+
this.send(command, optionsOrCb);
905+
} else if (typeof cb === "function") {
906+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
907+
this.send(command, optionsOrCb || {}, cb);
908+
} else {
909+
return this.send(command, optionsOrCb);
910+
}
911+
}
912+
882913
/**
883914
* <p>Performs a manual search against the specified assistant. To retrieve recommendations for
884915
* an assistant, use <a href="https://docs.aws.amazon.com/wisdom/latest/APIReference/API_GetRecommendations.html">GetRecommendations</a>.

clients/client-wisdom/src/WisdomClient.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ import {
9999
NotifyRecommendationsReceivedCommandInput,
100100
NotifyRecommendationsReceivedCommandOutput,
101101
} from "./commands/NotifyRecommendationsReceivedCommand";
102+
import { PutFeedbackCommandInput, PutFeedbackCommandOutput } from "./commands/PutFeedbackCommand";
102103
import { QueryAssistantCommandInput, QueryAssistantCommandOutput } from "./commands/QueryAssistantCommand";
103104
import {
104105
RemoveKnowledgeBaseTemplateUriCommandInput,
@@ -139,6 +140,7 @@ export type ServiceInputTypes =
139140
| ListKnowledgeBasesCommandInput
140141
| ListTagsForResourceCommandInput
141142
| NotifyRecommendationsReceivedCommandInput
143+
| PutFeedbackCommandInput
142144
| QueryAssistantCommandInput
143145
| RemoveKnowledgeBaseTemplateUriCommandInput
144146
| SearchContentCommandInput
@@ -172,6 +174,7 @@ export type ServiceOutputTypes =
172174
| ListKnowledgeBasesCommandOutput
173175
| ListTagsForResourceCommandOutput
174176
| NotifyRecommendationsReceivedCommandOutput
177+
| PutFeedbackCommandOutput
175178
| QueryAssistantCommandOutput
176179
| RemoveKnowledgeBaseTemplateUriCommandOutput
177180
| SearchContentCommandOutput
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// smithy-typescript generated code
2+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
3+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
4+
import { Command as $Command } from "@aws-sdk/smithy-client";
5+
import {
6+
FinalizeHandlerArguments,
7+
Handler,
8+
HandlerExecutionContext,
9+
HttpHandlerOptions as __HttpHandlerOptions,
10+
MetadataBearer as __MetadataBearer,
11+
MiddlewareStack,
12+
SerdeContext as __SerdeContext,
13+
} from "@aws-sdk/types";
14+
15+
import {
16+
PutFeedbackRequest,
17+
PutFeedbackRequestFilterSensitiveLog,
18+
PutFeedbackResponse,
19+
PutFeedbackResponseFilterSensitiveLog,
20+
} from "../models/models_0";
21+
import {
22+
deserializeAws_restJson1PutFeedbackCommand,
23+
serializeAws_restJson1PutFeedbackCommand,
24+
} from "../protocols/Aws_restJson1";
25+
import { ServiceInputTypes, ServiceOutputTypes, WisdomClientResolvedConfig } from "../WisdomClient";
26+
27+
export interface PutFeedbackCommandInput extends PutFeedbackRequest {}
28+
export interface PutFeedbackCommandOutput extends PutFeedbackResponse, __MetadataBearer {}
29+
30+
/**
31+
* <p>Submits feedback to Wisdom. The feedback is used to improve future recommendations from
32+
* <a href="https://docs.aws.amazon.com/wisdom/latest/APIReference/API_GetRecommendations.html">GetRecommendations</a> or
33+
* results from <a href="https://docs.aws.amazon.com/wisdom/latest/APIReference/API_QueryAssistant.html">QueryAssistant</a>.
34+
* Feedback can be resubmitted up to 6 hours after submission.
35+
* </p>
36+
* @example
37+
* Use a bare-bones client and the command you need to make an API call.
38+
* ```javascript
39+
* import { WisdomClient, PutFeedbackCommand } from "@aws-sdk/client-wisdom"; // ES Modules import
40+
* // const { WisdomClient, PutFeedbackCommand } = require("@aws-sdk/client-wisdom"); // CommonJS import
41+
* const client = new WisdomClient(config);
42+
* const command = new PutFeedbackCommand(input);
43+
* const response = await client.send(command);
44+
* ```
45+
*
46+
* @see {@link PutFeedbackCommandInput} for command's `input` shape.
47+
* @see {@link PutFeedbackCommandOutput} for command's `response` shape.
48+
* @see {@link WisdomClientResolvedConfig | config} for WisdomClient's `config` shape.
49+
*
50+
*/
51+
export class PutFeedbackCommand extends $Command<
52+
PutFeedbackCommandInput,
53+
PutFeedbackCommandOutput,
54+
WisdomClientResolvedConfig
55+
> {
56+
// Start section: command_properties
57+
// End section: command_properties
58+
59+
constructor(readonly input: PutFeedbackCommandInput) {
60+
// Start section: command_constructor
61+
super();
62+
// End section: command_constructor
63+
}
64+
65+
/**
66+
* @internal
67+
*/
68+
resolveMiddleware(
69+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
70+
configuration: WisdomClientResolvedConfig,
71+
options?: __HttpHandlerOptions
72+
): Handler<PutFeedbackCommandInput, PutFeedbackCommandOutput> {
73+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
74+
75+
const stack = clientStack.concat(this.middlewareStack);
76+
77+
const { logger } = configuration;
78+
const clientName = "WisdomClient";
79+
const commandName = "PutFeedbackCommand";
80+
const handlerExecutionContext: HandlerExecutionContext = {
81+
logger,
82+
clientName,
83+
commandName,
84+
inputFilterSensitiveLog: PutFeedbackRequestFilterSensitiveLog,
85+
outputFilterSensitiveLog: PutFeedbackResponseFilterSensitiveLog,
86+
};
87+
const { requestHandler } = configuration;
88+
return stack.resolve(
89+
(request: FinalizeHandlerArguments<any>) =>
90+
requestHandler.handle(request.request as __HttpRequest, options || {}),
91+
handlerExecutionContext
92+
);
93+
}
94+
95+
private serialize(input: PutFeedbackCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
96+
return serializeAws_restJson1PutFeedbackCommand(input, context);
97+
}
98+
99+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<PutFeedbackCommandOutput> {
100+
return deserializeAws_restJson1PutFeedbackCommand(output, context);
101+
}
102+
103+
// Start section: command_body_extra
104+
// End section: command_body_extra
105+
}

clients/client-wisdom/src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export * from "./ListContentsCommand";
2121
export * from "./ListKnowledgeBasesCommand";
2222
export * from "./ListTagsForResourceCommand";
2323
export * from "./NotifyRecommendationsReceivedCommand";
24+
export * from "./PutFeedbackCommand";
2425
export * from "./QueryAssistantCommand";
2526
export * from "./RemoveKnowledgeBaseTemplateUriCommand";
2627
export * from "./SearchContentCommand";

clients/client-wisdom/src/models/models_0.ts

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,75 @@ export interface NotifyRecommendationsReceivedResponse {
890890
errors?: NotifyRecommendationsReceivedError[];
891891
}
892892

893+
export enum Relevance {
894+
HELPFUL = "HELPFUL",
895+
NOT_HELPFUL = "NOT_HELPFUL",
896+
}
897+
898+
/**
899+
* <p>The feedback to submit to Wisdom.</p>
900+
*/
901+
export interface FeedbackData {
902+
/**
903+
* <p>The relevance of the target this feedback is for.</p>
904+
*/
905+
relevance: Relevance | string | undefined;
906+
}
907+
908+
export enum TargetType {
909+
RECOMMENDATION = "RECOMMENDATION",
910+
RESULT = "RESULT",
911+
}
912+
913+
export interface PutFeedbackRequest {
914+
/**
915+
* <p>The identifier of the Wisdom assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.</p>
916+
*/
917+
assistantId: string | undefined;
918+
919+
/**
920+
* <p>The identifier of a recommendation. or The identifier of the result data.</p>
921+
*/
922+
targetId: string | undefined;
923+
924+
/**
925+
* <p>The type of the targetId for which The feedback. is targeted.</p>
926+
*/
927+
targetType: TargetType | string | undefined;
928+
929+
/**
930+
* <p>The feedback.</p>
931+
*/
932+
feedback: FeedbackData | undefined;
933+
}
934+
935+
export interface PutFeedbackResponse {
936+
/**
937+
* <p>The identifier of the Wisdom assistant.</p>
938+
*/
939+
assistantId: string | undefined;
940+
941+
/**
942+
* <p>The Amazon Resource Name (ARN) of the Wisdom assistant.</p>
943+
*/
944+
assistantArn: string | undefined;
945+
946+
/**
947+
* <p>The identifier of a recommendation. or The identifier of the result data.</p>
948+
*/
949+
targetId: string | undefined;
950+
951+
/**
952+
* <p>The type of the targetId for which The feedback. is targeted.</p>
953+
*/
954+
targetType: TargetType | string | undefined;
955+
956+
/**
957+
* <p>The feedback.</p>
958+
*/
959+
feedback: FeedbackData | undefined;
960+
}
961+
893962
export interface QueryAssistantRequest {
894963
/**
895964
* <p>The identifier of the Wisdom assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.</p>
@@ -2241,6 +2310,27 @@ export const NotifyRecommendationsReceivedResponseFilterSensitiveLog = (
22412310
...obj,
22422311
});
22432312

2313+
/**
2314+
* @internal
2315+
*/
2316+
export const FeedbackDataFilterSensitiveLog = (obj: FeedbackData): any => ({
2317+
...obj,
2318+
});
2319+
2320+
/**
2321+
* @internal
2322+
*/
2323+
export const PutFeedbackRequestFilterSensitiveLog = (obj: PutFeedbackRequest): any => ({
2324+
...obj,
2325+
});
2326+
2327+
/**
2328+
* @internal
2329+
*/
2330+
export const PutFeedbackResponseFilterSensitiveLog = (obj: PutFeedbackResponse): any => ({
2331+
...obj,
2332+
});
2333+
22442334
/**
22452335
* @internal
22462336
*/

0 commit comments

Comments
 (0)