diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/LICENSE.txt b/sdk/cognitiveservices/cognitiveservices-qnamaker/LICENSE.txt index ea8fb1516028..2d3163745319 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/LICENSE.txt +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2020 Microsoft +Copyright (c) 2021 Microsoft Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/README.md b/sdk/cognitiveservices/cognitiveservices-qnamaker/README.md index 824eba6f559d..7c33acf21329 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/README.md +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/README.md @@ -1,62 +1,71 @@ ## An isomorphic javascript sdk for - QnAMakerClient -This package contains an isomorphic SDK for editing and creating Knowledge Bases, its endpoints and keys. -For interacting with QnAMaker such as training and asking questions please see @azure/cognitiveservices-qnamaker-runtime. +This package contains an isomorphic SDK (runs both in node.js and in browsers) for QnAMakerClient. ### Currently supported environments -- Node.js version 6.x.x or higher -- Browser JavaScript +- [LTS versions of Node.js](https://nodejs.org/about/releases/) +- Latest versions of Safari, Chrome, Edge and Firefox. -### How to Install +### Prerequisites +You must have an [Azure subscription](https://azure.microsoft.com/free/). + +### How to install + +To use this SDK in your project, you will need to install two packages. +- `@azure/cognitiveservices-qnamaker` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: ```bash -npm install @azure/cognitiveservices-qnamaker +npm install --save @azure/cognitiveservices-qnamaker @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. ### How to use -#### nodejs - Authentication, client creation and getSettings endpointSettings as an example written in TypeScript. - -##### Install @azure/ms-rest-azure-js +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -```bash -npm install @azure/ms-rest-azure-js -``` +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. +#### nodejs - Authentication, client creation, and getSettings endpointSettings as an example written in JavaScript. ##### Sample code ```javascript -const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js"); +const { DefaultAzureCredential } = require("@azure/identity"); const { QnAMakerClient } = require("@azure/cognitiveservices-qnamaker"); - -async function main() { - const QNAMAKER_KEY = process.env["QNAMAKER_KEY"] || ""; - const QNAMAKER_ENDPOINT = process.env["QNAMAKER_ENDPOINT"] || ""; - - const cognitiveServicesCredentials = new CognitiveServicesCredentials(QNAMAKER_KEY); - const client = new QnAMakerClient(cognitiveServicesCredentials, QNAMAKER_ENDPOINT); - - const settings = await client.endpointSettings.getSettings(); - - console.log(`The result is: ${JSON.stringify(settings)}`); -} - -main(); +const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; + +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new QnAMakerClient(creds, subscriptionId); +client.endpointSettings.getSettings().then((result) => { + console.log("The result is:"); + console.log(result); +}).catch((err) => { + console.log("An error occurred:"); + console.error(err); +}); ``` -#### browser - Authentication, client creation and getSettings endpointSettings as an example written in JavaScript. +#### browser - Authentication, client creation, and getSettings endpointSettings as an example written in JavaScript. -##### Install @azure/ms-rest-browserauth - -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html ```html @@ -64,28 +73,24 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to @azure/cognitiveservices-qnamaker sample - @@ -96,4 +101,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/README.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/cognitiveservices/cognitiveservices-qnamaker/README.png) diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/package.json b/sdk/cognitiveservices/cognitiveservices-qnamaker/package.json index ed8b2d9aef5b..a4f88fe1aa67 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/package.json +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/package.json @@ -4,7 +4,8 @@ "description": "QnAMakerClient Library with typescript type definitions for node.js and browser.", "version": "3.2.0", "dependencies": { - "@azure/ms-rest-js": "^2.0.4", + "@azure/ms-rest-js": "^2.2.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.10.0" }, "keywords": [ @@ -19,13 +20,13 @@ "module": "./esm/qnAMakerClient.js", "types": "./esm/qnAMakerClient.d.ts", "devDependencies": { - "typescript": "^3.5.3", + "typescript": "^3.6.0", "rollup": "^1.18.0", "rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-sourcemaps": "^0.4.2", "uglify-js": "^3.6.0" }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/cognitiveservices/cognitiveservices-qnamaker", + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/cognitiveservices/cognitiveservices-qnamaker", "repository": { "type": "git", "url": "https://github.com/Azure/azure-sdk-for-js.git" diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/index.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/index.ts index 4812cbc54ea3..073078447aa8 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/index.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/index.ts @@ -69,10 +69,6 @@ export interface UpdateKbContentsDTO { * List of existing URLs to be refreshed. The content will be extracted again and re-indexed. */ urls?: string[]; - /** - * Default answer sent to user if no good match is found in the KB. - */ - defaultAnswer?: string; } /** @@ -249,10 +245,6 @@ export interface QnADTO { * Context of a QnA */ context?: QnADTOContext; - /** - * Timestamp when the QnA was last updated. - */ - lastUpdatedTimestamp?: string; } /** @@ -365,14 +357,6 @@ export interface CreateKbDTO { * href="https://aka.ms/qnamaker-languages#languages-supported" target="_blank">here. */ language?: string; - /** - * Set to true to enable creating KBs in different languages for the same resource. - */ - enableMultipleLanguages?: boolean; - /** - * Default answer sent to user if no good match is found in the KB. - */ - defaultAnswer?: string; } /** @@ -607,221 +591,19 @@ export interface EndpointKeysDTO { language?: string; } -/** - * Context object with previous QnA's information. - */ -export interface QueryContextDTO { - /** - * Previous QnA Id - qnaId of the top result. - */ - previousQnaId?: number; - /** - * Previous user query. - */ - previousUserQuery?: string; -} - -/** - * Context object with previous QnA's information. - */ -export interface QueryDTOContext extends QueryContextDTO { -} - -/** - * To configure Answer span prediction feature. - */ -export interface AnswerSpanRequestDTO { - /** - * Enable or Disable Answer Span prediction. - */ - enable?: boolean; - /** - * Minimum threshold score required to include an answer span. - */ - scoreThreshold?: number; - /** - * Number of Top answers to be considered for span prediction. - */ - topAnswersWithSpan?: number; -} - -/** - * To configure Answer span prediction feature. - */ -export interface QueryDTOAnswerSpanRequest extends AnswerSpanRequestDTO { -} - -/** - * POST body schema to query the knowledgebase. - */ -export interface QueryDTO { - /** - * Exact qnaId to fetch from the knowledgebase, this field takes priority over question. - */ - qnaId?: string; - /** - * User question to query against the knowledge base. - */ - question?: string; - /** - * Max number of answers to be returned for the question. - */ - top?: number; - /** - * Unique identifier for the user. - */ - userId?: string; - /** - * Query against the test index. - */ - isTest?: boolean; - /** - * Minimum threshold score for answers. - */ - scoreThreshold?: number; - /** - * Context object with previous QnA's information. - */ - context?: QueryDTOContext; - /** - * Optional field. Set to 'QuestionOnly' for using a question only Ranker. - */ - rankerType?: string; - /** - * Find QnAs that are associated with the given list of metadata. - */ - strictFilters?: MetadataDTO[]; - /** - * Optional field. Set to 'OR' for using OR operation for strict filters. Possible values - * include: 'AND', 'OR' - */ - strictFiltersCompoundOperationType?: StrictFiltersCompoundOperationType; - /** - * To configure Answer span prediction feature. - */ - answerSpanRequest?: QueryDTOAnswerSpanRequest; -} - -/** - * Context object of the QnA - */ -export interface QnASearchResultContext extends ContextDTO { -} - -/** - * Answer span object of QnA. - */ -export interface AnswerSpanResponseDTO { - /** - * Predicted text of answer span. - */ - text?: string; - /** - * Predicted score of answer span. - */ - score?: number; - /** - * Start index of answer span in answer. - */ - startIndex?: number; - /** - * End index of answer span in answer. - */ - endIndex?: number; -} - -/** - * Answer span object of QnA with respect to user's question. - */ -export interface QnASearchResultAnswerSpan extends AnswerSpanResponseDTO { -} - -/** - * Represents Search Result. - */ -export interface QnASearchResult { - /** - * List of questions. - */ - questions?: string[]; - /** - * Answer. - */ - answer?: string; - /** - * Search result score. - */ - score?: number; - /** - * Id of the QnA result. - */ - id?: number; - /** - * Source of QnA result. - */ - source?: string; - /** - * List of metadata. - */ - metadata?: MetadataDTO[]; - /** - * Context object of the QnA - */ - context?: QnASearchResultContext; - /** - * Answer span object of QnA with respect to user's question. - */ - answerSpan?: QnASearchResultAnswerSpan; -} - -/** - * Represents List of Question Answers. - */ -export interface QnASearchResultList { - /** - * Represents Search Result list. - */ - answers?: QnASearchResult[]; -} - -/** - * Active learning feedback record. - */ -export interface FeedbackRecordDTO { - /** - * Unique identifier for the user. - */ - userId?: string; - /** - * The suggested question being provided as feedback. - */ - userQuestion?: string; - /** - * The qnaId for which the suggested question is provided as feedback. - */ - qnaId?: number; -} - -/** - * Active learning feedback records. - */ -export interface FeedbackRecordsDTO { - /** - * List of feedback records. - */ - feedbackRecords?: FeedbackRecordDTO[]; -} - /** * Optional Parameters. */ export interface KnowledgebaseDownloadOptionalParams extends msRest.RequestOptionsBase { /** - * The source property filter to apply. + * The source property filter to apply. Sample value: Editorial, smartLight%20FAQ.tsv . */ source?: string; /** - * The last changed status property filter to apply. + * changedSince property is used to return all QnAs created or updated after a specific time + * duration. The user can filter QnAs by seconds (s), minutes (m), hours (h) and days (d). The + * user may use any integral value along with the suffix for time. For instance, the value of 5m + * returns all QnA pairs updated or created in the last 5 minutes. */ changedSince?: string; } @@ -866,14 +648,6 @@ export type ErrorCodeType = 'BadArgument' | 'Forbidden' | 'NotFound' | 'KbNotFou */ export type OperationStateType = 'Failed' | 'NotStarted' | 'Running' | 'Succeeded'; -/** - * Defines values for StrictFiltersCompoundOperationType. - * Possible values include: 'AND', 'OR' - * @readonly - * @enum {string} - */ -export type StrictFiltersCompoundOperationType = 'AND' | 'OR'; - /** * Defines values for EnvironmentType. * Possible values include: 'Prod', 'Test' @@ -962,26 +736,6 @@ export type AlterationsGetResponse = WordAlterationsDTO & { }; }; -/** - * Contains response data for the getAlterationsForKb operation. - */ -export type AlterationsGetAlterationsForKbResponse = WordAlterationsDTO & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: WordAlterationsDTO; - }; -}; - /** * Contains response data for the listAll operation. */ @@ -1087,26 +841,6 @@ export type KnowledgebaseDownloadResponse = QnADocumentsDTO & { }; }; -/** - * Contains response data for the generateAnswer operation. - */ -export type KnowledgebaseGenerateAnswerResponse = QnASearchResultList & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: QnASearchResultList; - }; -}; - /** * Contains response data for the getDetails operation. */ diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/knowledgebaseMappers.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/knowledgebaseMappers.ts index a034bb7cce6a..184dbdab9c65 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/knowledgebaseMappers.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/knowledgebaseMappers.ts @@ -7,8 +7,6 @@ */ export { - AnswerSpanRequestDTO, - AnswerSpanResponseDTO, ContextDTO, CreateKbDTO, CreateKbInputDTO, @@ -16,8 +14,6 @@ export { ErrorModel, ErrorResponse, ErrorResponseError, - FeedbackRecordDTO, - FeedbackRecordsDTO, FileDTO, InnerErrorModel, KnowledgebaseDTO, @@ -30,14 +26,6 @@ export { QnADocumentsDTO, QnADTO, QnADTOContext, - QnASearchResult, - QnASearchResultAnswerSpan, - QnASearchResultContext, - QnASearchResultList, - QueryContextDTO, - QueryDTO, - QueryDTOAnswerSpanRequest, - QueryDTOContext, ReplaceKbDTO, UpdateContextDTO, UpdateKbContentsDTO, diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/mappers.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/mappers.ts index 9924b290f994..db8c111fc7e9 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/mappers.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/mappers.ts @@ -142,16 +142,6 @@ export const UpdateKbContentsDTO: msRest.CompositeMapper = { } } } - }, - defaultAnswer: { - serializedName: "defaultAnswer", - constraints: { - MaxLength: 300, - MinLength: 1 - }, - type: { - name: "String" - } } } } @@ -503,15 +493,6 @@ export const QnADTO: msRest.CompositeMapper = { name: "Composite", className: "QnADTOContext" } - }, - lastUpdatedTimestamp: { - serializedName: "lastUpdatedTimestamp", - constraints: { - MaxLength: 300 - }, - type: { - name: "String" - } } } } @@ -735,22 +716,6 @@ export const CreateKbDTO: msRest.CompositeMapper = { type: { name: "String" } - }, - enableMultipleLanguages: { - serializedName: "enableMultipleLanguages", - type: { - name: "Boolean" - } - }, - defaultAnswer: { - serializedName: "defaultAnswer", - constraints: { - MaxLength: 300, - MinLength: 1 - }, - type: { - name: "String" - } } } } @@ -1156,368 +1121,6 @@ export const EndpointKeysDTO: msRest.CompositeMapper = { } }; -export const QueryContextDTO: msRest.CompositeMapper = { - serializedName: "QueryContextDTO", - type: { - name: "Composite", - className: "QueryContextDTO", - modelProperties: { - previousQnaId: { - serializedName: "previousQnaId", - type: { - name: "Number" - } - }, - previousUserQuery: { - serializedName: "previousUserQuery", - type: { - name: "String" - } - } - } - } -}; - -export const QueryDTOContext: msRest.CompositeMapper = { - serializedName: "QueryDTO_context", - type: { - name: "Composite", - className: "QueryDTOContext", - modelProperties: { - ...QueryContextDTO.type.modelProperties - } - } -}; - -export const AnswerSpanRequestDTO: msRest.CompositeMapper = { - serializedName: "AnswerSpanRequestDTO", - type: { - name: "Composite", - className: "AnswerSpanRequestDTO", - modelProperties: { - enable: { - serializedName: "enable", - type: { - name: "Boolean" - } - }, - scoreThreshold: { - serializedName: "scoreThreshold", - type: { - name: "Number" - } - }, - topAnswersWithSpan: { - serializedName: "topAnswersWithSpan", - constraints: { - InclusiveMaximum: 10, - InclusiveMinimum: 1 - }, - type: { - name: "Number" - } - } - } - } -}; - -export const QueryDTOAnswerSpanRequest: msRest.CompositeMapper = { - serializedName: "QueryDTO_answerSpanRequest", - type: { - name: "Composite", - className: "QueryDTOAnswerSpanRequest", - modelProperties: { - ...AnswerSpanRequestDTO.type.modelProperties - } - } -}; - -export const QueryDTO: msRest.CompositeMapper = { - serializedName: "QueryDTO", - type: { - name: "Composite", - className: "QueryDTO", - modelProperties: { - qnaId: { - serializedName: "qnaId", - type: { - name: "String" - } - }, - question: { - serializedName: "question", - type: { - name: "String" - } - }, - top: { - serializedName: "top", - type: { - name: "Number" - } - }, - userId: { - serializedName: "userId", - type: { - name: "String" - } - }, - isTest: { - serializedName: "isTest", - type: { - name: "Boolean" - } - }, - scoreThreshold: { - serializedName: "scoreThreshold", - type: { - name: "Number" - } - }, - context: { - serializedName: "context", - type: { - name: "Composite", - className: "QueryDTOContext" - } - }, - rankerType: { - serializedName: "rankerType", - type: { - name: "String" - } - }, - strictFilters: { - serializedName: "strictFilters", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "MetadataDTO" - } - } - } - }, - strictFiltersCompoundOperationType: { - serializedName: "strictFiltersCompoundOperationType", - type: { - name: "String" - } - }, - answerSpanRequest: { - serializedName: "answerSpanRequest", - type: { - name: "Composite", - className: "QueryDTOAnswerSpanRequest" - } - } - } - } -}; - -export const QnASearchResultContext: msRest.CompositeMapper = { - serializedName: "QnASearchResult_context", - type: { - name: "Composite", - className: "QnASearchResultContext", - modelProperties: { - ...ContextDTO.type.modelProperties - } - } -}; - -export const AnswerSpanResponseDTO: msRest.CompositeMapper = { - serializedName: "AnswerSpanResponseDTO", - type: { - name: "Composite", - className: "AnswerSpanResponseDTO", - modelProperties: { - text: { - serializedName: "text", - type: { - name: "String" - } - }, - score: { - serializedName: "score", - type: { - name: "Number" - } - }, - startIndex: { - serializedName: "startIndex", - type: { - name: "Number" - } - }, - endIndex: { - serializedName: "endIndex", - type: { - name: "Number" - } - } - } - } -}; - -export const QnASearchResultAnswerSpan: msRest.CompositeMapper = { - serializedName: "QnASearchResult_answerSpan", - type: { - name: "Composite", - className: "QnASearchResultAnswerSpan", - modelProperties: { - ...AnswerSpanResponseDTO.type.modelProperties - } - } -}; - -export const QnASearchResult: msRest.CompositeMapper = { - serializedName: "QnASearchResult", - type: { - name: "Composite", - className: "QnASearchResult", - modelProperties: { - questions: { - serializedName: "questions", - type: { - name: "Sequence", - element: { - type: { - name: "String" - } - } - } - }, - answer: { - serializedName: "answer", - type: { - name: "String" - } - }, - score: { - serializedName: "score", - type: { - name: "Number" - } - }, - id: { - serializedName: "id", - type: { - name: "Number" - } - }, - source: { - serializedName: "source", - type: { - name: "String" - } - }, - metadata: { - serializedName: "metadata", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "MetadataDTO" - } - } - } - }, - context: { - serializedName: "context", - type: { - name: "Composite", - className: "QnASearchResultContext" - } - }, - answerSpan: { - serializedName: "answerSpan", - type: { - name: "Composite", - className: "QnASearchResultAnswerSpan" - } - } - } - } -}; - -export const QnASearchResultList: msRest.CompositeMapper = { - serializedName: "QnASearchResultList", - type: { - name: "Composite", - className: "QnASearchResultList", - modelProperties: { - answers: { - serializedName: "answers", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "QnASearchResult" - } - } - } - } - } - } -}; - -export const FeedbackRecordDTO: msRest.CompositeMapper = { - serializedName: "FeedbackRecordDTO", - type: { - name: "Composite", - className: "FeedbackRecordDTO", - modelProperties: { - userId: { - serializedName: "userId", - type: { - name: "String" - } - }, - userQuestion: { - serializedName: "userQuestion", - constraints: { - MaxLength: 1000 - }, - type: { - name: "String" - } - }, - qnaId: { - serializedName: "qnaId", - type: { - name: "Number" - } - } - } - } -}; - -export const FeedbackRecordsDTO: msRest.CompositeMapper = { - serializedName: "FeedbackRecordsDTO", - type: { - name: "Composite", - className: "FeedbackRecordsDTO", - modelProperties: { - feedbackRecords: { - serializedName: "feedbackRecords", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "FeedbackRecordDTO" - } - } - } - } - } - } -}; - export const OperationsGetDetailsHeaders: msRest.CompositeMapper = { serializedName: "operations-getdetails-headers", type: { diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/alterations.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/alterations.ts index 2460696a7eea..e9de5e92c9a7 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/alterations.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/alterations.ts @@ -76,66 +76,6 @@ export class Alterations { replaceOperationSpec, callback); } - - /** - * @summary Download alterations per Knowledgebase (QnAMaker Managed). - * @param kbId Knowledgebase id. - * @param [options] The optional parameters - * @returns Promise - */ - getAlterationsForKb(kbId: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param kbId Knowledgebase id. - * @param callback The callback - */ - getAlterationsForKb(kbId: string, callback: msRest.ServiceCallback): void; - /** - * @param kbId Knowledgebase id. - * @param options The optional parameters - * @param callback The callback - */ - getAlterationsForKb(kbId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - getAlterationsForKb(kbId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - kbId, - options - }, - getAlterationsForKbOperationSpec, - callback) as Promise; - } - - /** - * @summary Replace alterations data per Knowledgebase (QnAMaker Managed). - * @param kbId Knowledgebase id. - * @param wordAlterations New alterations data. - * @param [options] The optional parameters - * @returns Promise - */ - replaceAlterationsForKb(kbId: string, wordAlterations: Models.WordAlterationsDTO, options?: msRest.RequestOptionsBase): Promise; - /** - * @param kbId Knowledgebase id. - * @param wordAlterations New alterations data. - * @param callback The callback - */ - replaceAlterationsForKb(kbId: string, wordAlterations: Models.WordAlterationsDTO, callback: msRest.ServiceCallback): void; - /** - * @param kbId Knowledgebase id. - * @param wordAlterations New alterations data. - * @param options The optional parameters - * @param callback The callback - */ - replaceAlterationsForKb(kbId: string, wordAlterations: Models.WordAlterationsDTO, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - replaceAlterationsForKb(kbId: string, wordAlterations: Models.WordAlterationsDTO, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - kbId, - wordAlterations, - options - }, - replaceAlterationsForKbOperationSpec, - callback); - } } // Operation Specifications @@ -178,44 +118,3 @@ const replaceOperationSpec: msRest.OperationSpec = { }, serializer }; - -const getAlterationsForKbOperationSpec: msRest.OperationSpec = { - httpMethod: "GET", - path: "alterations/{kbId}", - urlParameters: [ - Parameters.endpoint, - Parameters.kbId - ], - responses: { - 200: { - bodyMapper: Mappers.WordAlterationsDTO - }, - default: { - bodyMapper: Mappers.ErrorResponse - } - }, - serializer -}; - -const replaceAlterationsForKbOperationSpec: msRest.OperationSpec = { - httpMethod: "PUT", - path: "alterations/{kbId}", - urlParameters: [ - Parameters.endpoint, - Parameters.kbId - ], - requestBody: { - parameterPath: "wordAlterations", - mapper: { - ...Mappers.WordAlterationsDTO, - required: true - } - }, - responses: { - 204: {}, - default: { - bodyMapper: Mappers.ErrorResponse - } - }, - serializer -}; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/knowledgebase.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/knowledgebase.ts index 28416e55e0c1..c0fef7939d7b 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/knowledgebase.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/knowledgebase.ts @@ -259,70 +259,6 @@ export class Knowledgebase { downloadOperationSpec, callback) as Promise; } - - /** - * @summary GenerateAnswer call to query knowledgebase (QnA Maker Managed). - * @param kbId Knowledgebase id. - * @param generateAnswerPayload Post body of the request. - * @param [options] The optional parameters - * @returns Promise - */ - generateAnswer(kbId: string, generateAnswerPayload: Models.QueryDTO, options?: msRest.RequestOptionsBase): Promise; - /** - * @param kbId Knowledgebase id. - * @param generateAnswerPayload Post body of the request. - * @param callback The callback - */ - generateAnswer(kbId: string, generateAnswerPayload: Models.QueryDTO, callback: msRest.ServiceCallback): void; - /** - * @param kbId Knowledgebase id. - * @param generateAnswerPayload Post body of the request. - * @param options The optional parameters - * @param callback The callback - */ - generateAnswer(kbId: string, generateAnswerPayload: Models.QueryDTO, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - generateAnswer(kbId: string, generateAnswerPayload: Models.QueryDTO, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - kbId, - generateAnswerPayload, - options - }, - generateAnswerOperationSpec, - callback) as Promise; - } - - /** - * @summary Train call to add suggestions to knowledgebase (QnAMaker Managed). - * @param kbId Knowledgebase id. - * @param trainPayload Post body of the request. - * @param [options] The optional parameters - * @returns Promise - */ - train(kbId: string, trainPayload: Models.FeedbackRecordsDTO, options?: msRest.RequestOptionsBase): Promise; - /** - * @param kbId Knowledgebase id. - * @param trainPayload Post body of the request. - * @param callback The callback - */ - train(kbId: string, trainPayload: Models.FeedbackRecordsDTO, callback: msRest.ServiceCallback): void; - /** - * @param kbId Knowledgebase id. - * @param trainPayload Post body of the request. - * @param options The optional parameters - * @param callback The callback - */ - train(kbId: string, trainPayload: Models.FeedbackRecordsDTO, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - train(kbId: string, trainPayload: Models.FeedbackRecordsDTO, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - kbId, - trainPayload, - options - }, - trainOperationSpec, - callback); - } } // Operation Specifications @@ -490,51 +426,3 @@ const downloadOperationSpec: msRest.OperationSpec = { }, serializer }; - -const generateAnswerOperationSpec: msRest.OperationSpec = { - httpMethod: "POST", - path: "knowledgebases/{kbId}/generateAnswer", - urlParameters: [ - Parameters.endpoint, - Parameters.kbId - ], - requestBody: { - parameterPath: "generateAnswerPayload", - mapper: { - ...Mappers.QueryDTO, - required: true - } - }, - responses: { - 200: { - bodyMapper: Mappers.QnASearchResultList - }, - default: { - bodyMapper: Mappers.ErrorResponse - } - }, - serializer -}; - -const trainOperationSpec: msRest.OperationSpec = { - httpMethod: "POST", - path: "knowledgebases/{kbId}/train", - urlParameters: [ - Parameters.endpoint, - Parameters.kbId - ], - requestBody: { - parameterPath: "trainPayload", - mapper: { - ...Mappers.FeedbackRecordsDTO, - required: true - } - }, - responses: { - 204: {}, - default: { - bodyMapper: Mappers.ErrorResponse - } - }, - serializer -}; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClient.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClient.ts index 5690ed0a3612..f6b86d74e875 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClient.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClient.ts @@ -23,12 +23,17 @@ class QnAMakerClient extends QnAMakerClientContext { /** * Initializes a new instance of the QnAMakerClient class. - * @param endpoint Supported Cognitive Services endpoint (e.g., https://< qnamaker-resource-name - * >.api.cognitiveservices.azure.com). + * @param endpoint Supported Cognitive Services endpoint (e.g., https://< qnamaker-resource-name> + * .api.cognitiveservices.azure.com). * @param credentials Subscription credentials which uniquely identify client subscription. + * Credentials implementing the TokenCredential interface from the @azure/identity package are + * recommended. For more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, endpoint: string, options?: msRest.ServiceClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, endpoint: string, options?: msRest.ServiceClientOptions) { super(credentials, endpoint, options); this.endpointSettings = new operations.EndpointSettings(this); this.endpointKeys = new operations.EndpointKeys(this); diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClientContext.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClientContext.ts index 00597b9a5f08..d3093a24de11 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClientContext.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClientContext.ts @@ -14,16 +14,21 @@ const packageVersion = "3.2.0"; export class QnAMakerClientContext extends msRest.ServiceClient { endpoint: string; - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; /** * Initializes a new instance of the QnAMakerClientContext class. - * @param endpoint Supported Cognitive Services endpoint (e.g., https://< qnamaker-resource-name - * >.api.cognitiveservices.azure.com). + * @param endpoint Supported Cognitive Services endpoint (e.g., https://< qnamaker-resource-name> + * .api.cognitiveservices.azure.com). * @param credentials Subscription credentials which uniquely identify client subscription. + * Credentials implementing the TokenCredential interface from the @azure/identity package are + * recommended. For more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, endpoint: string, options?: msRest.ServiceClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, endpoint: string, options?: msRest.ServiceClientOptions) { if (endpoint == undefined) { throw new Error("'endpoint' cannot be null."); } @@ -42,7 +47,7 @@ export class QnAMakerClientContext extends msRest.ServiceClient { super(credentials, options); - this.baseUri = "{Endpoint}/qnamaker/v5.0-preview.1"; + this.baseUri = "{Endpoint}/qnamaker/v4.0"; this.requestContentType = "application/json; charset=utf-8"; this.endpoint = endpoint; this.credentials = credentials;