diff --git a/clients/client-wisdom/src/Wisdom.ts b/clients/client-wisdom/src/Wisdom.ts index 37e2409f42f3..12ab92aeed48 100644 --- a/clients/client-wisdom/src/Wisdom.ts +++ b/clients/client-wisdom/src/Wisdom.ts @@ -103,6 +103,7 @@ import { NotifyRecommendationsReceivedCommandInput, NotifyRecommendationsReceivedCommandOutput, } from "./commands/NotifyRecommendationsReceivedCommand"; +import { PutFeedbackCommand, PutFeedbackCommandInput, PutFeedbackCommandOutput } from "./commands/PutFeedbackCommand"; import { QueryAssistantCommand, QueryAssistantCommandInput, @@ -879,6 +880,36 @@ export class Wisdom extends WisdomClient { } } + /** + *
Submits feedback to Wisdom. The feedback is used to improve future recommendations from + * GetRecommendations or + * results from QueryAssistant. + * Feedback can be resubmitted up to 6 hours after submission. + *
+ */ + public putFeedback(args: PutFeedbackCommandInput, options?: __HttpHandlerOptions): PromisePerforms a manual search against the specified assistant. To retrieve recommendations for * an assistant, use GetRecommendations. diff --git a/clients/client-wisdom/src/WisdomClient.ts b/clients/client-wisdom/src/WisdomClient.ts index df3e050e25dc..754ea5cce613 100644 --- a/clients/client-wisdom/src/WisdomClient.ts +++ b/clients/client-wisdom/src/WisdomClient.ts @@ -99,6 +99,7 @@ import { NotifyRecommendationsReceivedCommandInput, NotifyRecommendationsReceivedCommandOutput, } from "./commands/NotifyRecommendationsReceivedCommand"; +import { PutFeedbackCommandInput, PutFeedbackCommandOutput } from "./commands/PutFeedbackCommand"; import { QueryAssistantCommandInput, QueryAssistantCommandOutput } from "./commands/QueryAssistantCommand"; import { RemoveKnowledgeBaseTemplateUriCommandInput, @@ -139,6 +140,7 @@ export type ServiceInputTypes = | ListKnowledgeBasesCommandInput | ListTagsForResourceCommandInput | NotifyRecommendationsReceivedCommandInput + | PutFeedbackCommandInput | QueryAssistantCommandInput | RemoveKnowledgeBaseTemplateUriCommandInput | SearchContentCommandInput @@ -172,6 +174,7 @@ export type ServiceOutputTypes = | ListKnowledgeBasesCommandOutput | ListTagsForResourceCommandOutput | NotifyRecommendationsReceivedCommandOutput + | PutFeedbackCommandOutput | QueryAssistantCommandOutput | RemoveKnowledgeBaseTemplateUriCommandOutput | SearchContentCommandOutput diff --git a/clients/client-wisdom/src/commands/PutFeedbackCommand.ts b/clients/client-wisdom/src/commands/PutFeedbackCommand.ts new file mode 100644 index 000000000000..57068395f56d --- /dev/null +++ b/clients/client-wisdom/src/commands/PutFeedbackCommand.ts @@ -0,0 +1,105 @@ +// smithy-typescript generated code +import { getSerdePlugin } from "@aws-sdk/middleware-serde"; +import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http"; +import { Command as $Command } from "@aws-sdk/smithy-client"; +import { + FinalizeHandlerArguments, + Handler, + HandlerExecutionContext, + HttpHandlerOptions as __HttpHandlerOptions, + MetadataBearer as __MetadataBearer, + MiddlewareStack, + SerdeContext as __SerdeContext, +} from "@aws-sdk/types"; + +import { + PutFeedbackRequest, + PutFeedbackRequestFilterSensitiveLog, + PutFeedbackResponse, + PutFeedbackResponseFilterSensitiveLog, +} from "../models/models_0"; +import { + deserializeAws_restJson1PutFeedbackCommand, + serializeAws_restJson1PutFeedbackCommand, +} from "../protocols/Aws_restJson1"; +import { ServiceInputTypes, ServiceOutputTypes, WisdomClientResolvedConfig } from "../WisdomClient"; + +export interface PutFeedbackCommandInput extends PutFeedbackRequest {} +export interface PutFeedbackCommandOutput extends PutFeedbackResponse, __MetadataBearer {} + +/** + *
Submits feedback to Wisdom. The feedback is used to improve future recommendations from + * GetRecommendations or + * results from QueryAssistant. + * Feedback can be resubmitted up to 6 hours after submission. + *
+ * @example + * Use a bare-bones client and the command you need to make an API call. + * ```javascript + * import { WisdomClient, PutFeedbackCommand } from "@aws-sdk/client-wisdom"; // ES Modules import + * // const { WisdomClient, PutFeedbackCommand } = require("@aws-sdk/client-wisdom"); // CommonJS import + * const client = new WisdomClient(config); + * const command = new PutFeedbackCommand(input); + * const response = await client.send(command); + * ``` + * + * @see {@link PutFeedbackCommandInput} for command's `input` shape. + * @see {@link PutFeedbackCommandOutput} for command's `response` shape. + * @see {@link WisdomClientResolvedConfig | config} for WisdomClient's `config` shape. + * + */ +export class PutFeedbackCommand extends $Command< + PutFeedbackCommandInput, + PutFeedbackCommandOutput, + WisdomClientResolvedConfig +> { + // Start section: command_properties + // End section: command_properties + + constructor(readonly input: PutFeedbackCommandInput) { + // Start section: command_constructor + super(); + // End section: command_constructor + } + + /** + * @internal + */ + resolveMiddleware( + clientStack: MiddlewareStackThe feedback to submit to Wisdom.
+ */ +export interface FeedbackData { + /** + *The relevance of the target this feedback is for.
+ */ + relevance: Relevance | string | undefined; +} + +export enum TargetType { + RECOMMENDATION = "RECOMMENDATION", + RESULT = "RESULT", +} + +export interface PutFeedbackRequest { + /** + *The identifier of the Wisdom assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.
+ */ + assistantId: string | undefined; + + /** + *The identifier of a recommendation. or The identifier of the result data.
+ */ + targetId: string | undefined; + + /** + *The type of the targetId for which The feedback. is targeted.
+ */ + targetType: TargetType | string | undefined; + + /** + *The feedback.
+ */ + feedback: FeedbackData | undefined; +} + +export interface PutFeedbackResponse { + /** + *The identifier of the Wisdom assistant.
+ */ + assistantId: string | undefined; + + /** + *The Amazon Resource Name (ARN) of the Wisdom assistant.
+ */ + assistantArn: string | undefined; + + /** + *The identifier of a recommendation. or The identifier of the result data.
+ */ + targetId: string | undefined; + + /** + *The type of the targetId for which The feedback. is targeted.
+ */ + targetType: TargetType | string | undefined; + + /** + *The feedback.
+ */ + feedback: FeedbackData | undefined; +} + export interface QueryAssistantRequest { /** *The identifier of the Wisdom assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.
@@ -2241,6 +2310,27 @@ export const NotifyRecommendationsReceivedResponseFilterSensitiveLog = ( ...obj, }); +/** + * @internal + */ +export const FeedbackDataFilterSensitiveLog = (obj: FeedbackData): any => ({ + ...obj, +}); + +/** + * @internal + */ +export const PutFeedbackRequestFilterSensitiveLog = (obj: PutFeedbackRequest): any => ({ + ...obj, +}); + +/** + * @internal + */ +export const PutFeedbackResponseFilterSensitiveLog = (obj: PutFeedbackResponse): any => ({ + ...obj, +}); + /** * @internal */ diff --git a/clients/client-wisdom/src/protocols/Aws_restJson1.ts b/clients/client-wisdom/src/protocols/Aws_restJson1.ts index 12c043a37d28..3188938310e6 100644 --- a/clients/client-wisdom/src/protocols/Aws_restJson1.ts +++ b/clients/client-wisdom/src/protocols/Aws_restJson1.ts @@ -68,6 +68,7 @@ import { NotifyRecommendationsReceivedCommandInput, NotifyRecommendationsReceivedCommandOutput, } from "../commands/NotifyRecommendationsReceivedCommand"; +import { PutFeedbackCommandInput, PutFeedbackCommandOutput } from "../commands/PutFeedbackCommand"; import { QueryAssistantCommandInput, QueryAssistantCommandOutput } from "../commands/QueryAssistantCommand"; import { RemoveKnowledgeBaseTemplateUriCommandInput, @@ -98,6 +99,7 @@ import { ContentSummary, Document, DocumentText, + FeedbackData, Filter, Highlight, KnowledgeBaseAssociationData, @@ -754,6 +756,34 @@ export const serializeAws_restJson1NotifyRecommendationsReceivedCommand = async }); }; +export const serializeAws_restJson1PutFeedbackCommand = async ( + input: PutFeedbackCommandInput, + context: __SerdeContext +): Promise<__HttpRequest> => { + const { hostname, protocol = "https", port, path: basePath } = await context.endpoint(); + const headers: any = { + "content-type": "application/json", + }; + let resolvedPath = + `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/assistants/{assistantId}/feedback"; + resolvedPath = __resolvedPath(resolvedPath, input, "assistantId", () => input.assistantId!, "{assistantId}", false); + let body: any; + body = JSON.stringify({ + ...(input.feedback != null && { feedback: serializeAws_restJson1FeedbackData(input.feedback, context) }), + ...(input.targetId != null && { targetId: input.targetId }), + ...(input.targetType != null && { targetType: input.targetType }), + }); + return new __HttpRequest({ + protocol, + hostname, + port, + method: "PUT", + headers, + path: resolvedPath, + body, + }); +}; + export const serializeAws_restJson1QueryAssistantCommand = async ( input: QueryAssistantCommandInput, context: __SerdeContext @@ -2098,6 +2128,65 @@ const deserializeAws_restJson1NotifyRecommendationsReceivedCommandError = async } }; +export const deserializeAws_restJson1PutFeedbackCommand = async ( + output: __HttpResponse, + context: __SerdeContext +): PromiseThe text of the document.
" } }, + "com.amazonaws.wisdom#FeedbackData": { + "type": "structure", + "members": { + "relevance": { + "target": "com.amazonaws.wisdom#Relevance", + "traits": { + "smithy.api#documentation": "The relevance of the target this feedback is for.
", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "The feedback to submit to Wisdom.
" + } + }, "com.amazonaws.wisdom#Filter": { "type": "structure", "members": { @@ -2851,6 +2869,109 @@ "smithy.api#httpError": 412 } }, + "com.amazonaws.wisdom#PutFeedback": { + "type": "operation", + "input": { + "target": "com.amazonaws.wisdom#PutFeedbackRequest" + }, + "output": { + "target": "com.amazonaws.wisdom#PutFeedbackResponse" + }, + "errors": [ + { + "target": "com.amazonaws.wisdom#AccessDeniedException" + }, + { + "target": "com.amazonaws.wisdom#ResourceNotFoundException" + }, + { + "target": "com.amazonaws.wisdom#ValidationException" + } + ], + "traits": { + "smithy.api#documentation": "Submits feedback to Wisdom. The feedback is used to improve future recommendations from\n GetRecommendations or\n results from QueryAssistant.\n Feedback can be resubmitted up to 6 hours after submission.\n
", + "smithy.api#http": { + "uri": "/assistants/{assistantId}/feedback", + "method": "PUT" + }, + "smithy.api#idempotent": {}, + "smithy.api#private": {} + } + }, + "com.amazonaws.wisdom#PutFeedbackRequest": { + "type": "structure", + "members": { + "assistantId": { + "target": "com.amazonaws.wisdom#UuidOrArn", + "traits": { + "smithy.api#documentation": "The identifier of the Wisdom assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.
", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "targetId": { + "target": "smithy.api#String", + "traits": { + "smithy.api#documentation": "The identifier of a recommendation. or The identifier of the result data.
", + "smithy.api#required": {} + } + }, + "targetType": { + "target": "com.amazonaws.wisdom#TargetType", + "traits": { + "smithy.api#documentation": "The type of the targetId for which The feedback. is targeted.
", + "smithy.api#required": {} + } + }, + "feedback": { + "target": "com.amazonaws.wisdom#FeedbackData", + "traits": { + "smithy.api#documentation": "The feedback.
", + "smithy.api#required": {} + } + } + } + }, + "com.amazonaws.wisdom#PutFeedbackResponse": { + "type": "structure", + "members": { + "assistantId": { + "target": "com.amazonaws.wisdom#Uuid", + "traits": { + "smithy.api#documentation": "The identifier of the Wisdom assistant.
", + "smithy.api#required": {} + } + }, + "assistantArn": { + "target": "com.amazonaws.wisdom#UuidOrArn", + "traits": { + "smithy.api#documentation": "The Amazon Resource Name (ARN) of the Wisdom assistant.
", + "smithy.api#required": {} + } + }, + "targetId": { + "target": "com.amazonaws.wisdom#Uuid", + "traits": { + "smithy.api#documentation": "The identifier of a recommendation. or The identifier of the result data.
", + "smithy.api#required": {} + } + }, + "targetType": { + "target": "com.amazonaws.wisdom#TargetType", + "traits": { + "smithy.api#documentation": "The type of the targetId for which The feedback. is targeted.
", + "smithy.api#required": {} + } + }, + "feedback": { + "target": "com.amazonaws.wisdom#FeedbackData", + "traits": { + "smithy.api#documentation": "The feedback.
", + "smithy.api#required": {} + } + } + } + }, "com.amazonaws.wisdom#QueryAssistant": { "type": "operation", "input": { @@ -3118,6 +3239,21 @@ ] } }, + "com.amazonaws.wisdom#Relevance": { + "type": "string", + "traits": { + "smithy.api#enum": [ + { + "value": "HELPFUL", + "name": "HELPFUL" + }, + { + "value": "NOT_HELPFUL", + "name": "NOT_HELPFUL" + } + ] + } + }, "com.amazonaws.wisdom#RelevanceLevel": { "type": "string", "traits": { @@ -3761,6 +3897,21 @@ "target": "com.amazonaws.wisdom#TagValue" } }, + "com.amazonaws.wisdom#TargetType": { + "type": "string", + "traits": { + "smithy.api#enum": [ + { + "value": "RECOMMENDATION", + "name": "RECOMMENDATION" + }, + { + "value": "RESULT", + "name": "RESULT" + } + ] + } + }, "com.amazonaws.wisdom#TooManyTagsException": { "type": "structure", "members": {