Skip to content

Commit

Permalink
feat(client-wisdom): This release introduces a new API PutFeedback th…
Browse files Browse the repository at this point in the history
…at allows submitting feedback to Wisdom on content relevance.
  • Loading branch information
awstools committed Aug 15, 2022
1 parent 0f250fe commit 53b4df1
Show file tree
Hide file tree
Showing 7 changed files with 482 additions and 0 deletions.
31 changes: 31 additions & 0 deletions clients/client-wisdom/src/Wisdom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ import {
NotifyRecommendationsReceivedCommandInput,
NotifyRecommendationsReceivedCommandOutput,
} from "./commands/NotifyRecommendationsReceivedCommand";
import { PutFeedbackCommand, PutFeedbackCommandInput, PutFeedbackCommandOutput } from "./commands/PutFeedbackCommand";
import {
QueryAssistantCommand,
QueryAssistantCommandInput,
Expand Down Expand Up @@ -879,6 +880,36 @@ export class Wisdom extends WisdomClient {
}
}

/**
* <p>Submits feedback to Wisdom. The feedback is used to improve future recommendations from
* <a href="https://docs.aws.amazon.com/wisdom/latest/APIReference/API_GetRecommendations.html">GetRecommendations</a> or
* results from <a href="https://docs.aws.amazon.com/wisdom/latest/APIReference/API_QueryAssistant.html">QueryAssistant</a>.
* Feedback can be resubmitted up to 6 hours after submission.
* </p>
*/
public putFeedback(args: PutFeedbackCommandInput, options?: __HttpHandlerOptions): Promise<PutFeedbackCommandOutput>;
public putFeedback(args: PutFeedbackCommandInput, cb: (err: any, data?: PutFeedbackCommandOutput) => void): void;
public putFeedback(
args: PutFeedbackCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: PutFeedbackCommandOutput) => void
): void;
public putFeedback(
args: PutFeedbackCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: PutFeedbackCommandOutput) => void),
cb?: (err: any, data?: PutFeedbackCommandOutput) => void
): Promise<PutFeedbackCommandOutput> | void {
const command = new PutFeedbackCommand(args);
if (typeof optionsOrCb === "function") {
this.send(command, optionsOrCb);
} else if (typeof cb === "function") {
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
this.send(command, optionsOrCb || {}, cb);
} else {
return this.send(command, optionsOrCb);
}
}

/**
* <p>Performs a manual search against the specified assistant. To retrieve recommendations for
* an assistant, use <a href="https://docs.aws.amazon.com/wisdom/latest/APIReference/API_GetRecommendations.html">GetRecommendations</a>.
Expand Down
3 changes: 3 additions & 0 deletions clients/client-wisdom/src/WisdomClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ import {
NotifyRecommendationsReceivedCommandInput,
NotifyRecommendationsReceivedCommandOutput,
} from "./commands/NotifyRecommendationsReceivedCommand";
import { PutFeedbackCommandInput, PutFeedbackCommandOutput } from "./commands/PutFeedbackCommand";
import { QueryAssistantCommandInput, QueryAssistantCommandOutput } from "./commands/QueryAssistantCommand";
import {
RemoveKnowledgeBaseTemplateUriCommandInput,
Expand Down Expand Up @@ -139,6 +140,7 @@ export type ServiceInputTypes =
| ListKnowledgeBasesCommandInput
| ListTagsForResourceCommandInput
| NotifyRecommendationsReceivedCommandInput
| PutFeedbackCommandInput
| QueryAssistantCommandInput
| RemoveKnowledgeBaseTemplateUriCommandInput
| SearchContentCommandInput
Expand Down Expand Up @@ -172,6 +174,7 @@ export type ServiceOutputTypes =
| ListKnowledgeBasesCommandOutput
| ListTagsForResourceCommandOutput
| NotifyRecommendationsReceivedCommandOutput
| PutFeedbackCommandOutput
| QueryAssistantCommandOutput
| RemoveKnowledgeBaseTemplateUriCommandOutput
| SearchContentCommandOutput
Expand Down
105 changes: 105 additions & 0 deletions clients/client-wisdom/src/commands/PutFeedbackCommand.ts
Original file line number Diff line number Diff line change
@@ -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 {}

/**
* <p>Submits feedback to Wisdom. The feedback is used to improve future recommendations from
* <a href="https://docs.aws.amazon.com/wisdom/latest/APIReference/API_GetRecommendations.html">GetRecommendations</a> or
* results from <a href="https://docs.aws.amazon.com/wisdom/latest/APIReference/API_QueryAssistant.html">QueryAssistant</a>.
* Feedback can be resubmitted up to 6 hours after submission.
* </p>
* @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: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: WisdomClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<PutFeedbackCommandInput, PutFeedbackCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));

const stack = clientStack.concat(this.middlewareStack);

const { logger } = configuration;
const clientName = "WisdomClient";
const commandName = "PutFeedbackCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: PutFeedbackRequestFilterSensitiveLog,
outputFilterSensitiveLog: PutFeedbackResponseFilterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}

private serialize(input: PutFeedbackCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return serializeAws_restJson1PutFeedbackCommand(input, context);
}

private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<PutFeedbackCommandOutput> {
return deserializeAws_restJson1PutFeedbackCommand(output, context);
}

// Start section: command_body_extra
// End section: command_body_extra
}
1 change: 1 addition & 0 deletions clients/client-wisdom/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export * from "./ListContentsCommand";
export * from "./ListKnowledgeBasesCommand";
export * from "./ListTagsForResourceCommand";
export * from "./NotifyRecommendationsReceivedCommand";
export * from "./PutFeedbackCommand";
export * from "./QueryAssistantCommand";
export * from "./RemoveKnowledgeBaseTemplateUriCommand";
export * from "./SearchContentCommand";
Expand Down
90 changes: 90 additions & 0 deletions clients/client-wisdom/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,75 @@ export interface NotifyRecommendationsReceivedResponse {
errors?: NotifyRecommendationsReceivedError[];
}

export enum Relevance {
HELPFUL = "HELPFUL",
NOT_HELPFUL = "NOT_HELPFUL",
}

/**
* <p>The feedback to submit to Wisdom.</p>
*/
export interface FeedbackData {
/**
* <p>The relevance of the target this feedback is for.</p>
*/
relevance: Relevance | string | undefined;
}

export enum TargetType {
RECOMMENDATION = "RECOMMENDATION",
RESULT = "RESULT",
}

export interface PutFeedbackRequest {
/**
* <p>The identifier of the Wisdom assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.</p>
*/
assistantId: string | undefined;

/**
* <p>The identifier of a recommendation. or The identifier of the result data.</p>
*/
targetId: string | undefined;

/**
* <p>The type of the targetId for which The feedback. is targeted.</p>
*/
targetType: TargetType | string | undefined;

/**
* <p>The feedback.</p>
*/
feedback: FeedbackData | undefined;
}

export interface PutFeedbackResponse {
/**
* <p>The identifier of the Wisdom assistant.</p>
*/
assistantId: string | undefined;

/**
* <p>The Amazon Resource Name (ARN) of the Wisdom assistant.</p>
*/
assistantArn: string | undefined;

/**
* <p>The identifier of a recommendation. or The identifier of the result data.</p>
*/
targetId: string | undefined;

/**
* <p>The type of the targetId for which The feedback. is targeted.</p>
*/
targetType: TargetType | string | undefined;

/**
* <p>The feedback.</p>
*/
feedback: FeedbackData | undefined;
}

export interface QueryAssistantRequest {
/**
* <p>The identifier of the Wisdom assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.</p>
Expand Down Expand Up @@ -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
*/
Expand Down
Loading

0 comments on commit 53b4df1

Please sign in to comment.