From bc1ab4f78f7559384a7c2684f6f27b2a42010fb9 Mon Sep 17 00:00:00 2001 From: "openapi-bot[bot]" <37845953+openapi-bot[bot]@users.noreply.github.com> Date: Thu, 1 Aug 2019 15:44:00 +0000 Subject: [PATCH] Generated from 3d6f73607f9caee9054b290237825245306d7408 (#4494) ensure package directory and namespace match --- .../cognitiveservices-qnamaker/README.md | 99 +- .../cognitiveservices-qnamaker/package.json | 16 +- .../rollup.config.js | 2 +- .../src/models/endpointSettingsMappers.ts | 17 + .../src/models/index.ts | 625 ++---------- .../src/models/mappers.ts | 961 ++++-------------- .../src/models/parameters.ts | 45 +- .../src/models/runtimeMappers.ts | 28 + .../src/operations/endpointSettings.ts | 128 +++ .../src/operations/index.ts | 5 +- .../src/operations/runtime.ts | 142 +++ .../src/qnAMakerClient.ts | 2 + .../src/qnAMakerClientContext.ts | 2 +- .../src/qnAMakerRuntimeClient.ts | 42 + .../src/qnAMakerRuntimeClientContext.ts | 51 + .../cognitiveservices-qnamaker/tsconfig.json | 2 +- 16 files changed, 818 insertions(+), 1349 deletions(-) create mode 100644 sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/endpointSettingsMappers.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/runtimeMappers.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/endpointSettings.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/runtime.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerRuntimeClient.ts create mode 100644 sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerRuntimeClientContext.ts diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/README.md b/sdk/cognitiveservices/cognitiveservices-qnamaker/README.md index 9acb604fc652..ef25278cc89d 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/README.md +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/README.md @@ -1,6 +1,6 @@ -## An isomorphic javascript sdk for - QnAMakerClient +## An isomorphic javascript sdk for - QnAMakerRuntimeClient -This package contains an isomorphic SDK for QnAMakerClient. +This package contains an isomorphic SDK for QnAMakerRuntimeClient. ### Currently supported environments @@ -15,30 +15,62 @@ npm install @azure/cognitiveservices-qnamaker ### How to use -#### nodejs - Authentication, client creation and getKeys endpointKeys as an example written in TypeScript. +#### nodejs - Authentication, client creation and generateAnswer runtime as an example written in TypeScript. + +##### Install @azure/ms-rest-nodeauth + +```bash +npm install @azure/ms-rest-nodeauth +``` ##### Sample code ```typescript import * as msRest from "@azure/ms-rest-js"; import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; -import { QnAMakerClient, QnAMakerModels, QnAMakerMappers } from "@azure/cognitiveservices-qnamaker"; +import { QnAMakerRuntimeClient, QnAMakerRuntimeModels, QnAMakerRuntimeMappers } from "@azure/cognitiveservices-qnamaker"; const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -const endpoint = "https://westus.api.cognitive.microsoft.com"; // OR some other endpoint. -const creds = new msRest.ApiKeyCredentials({ inHeader: { 'Ocp-Apim-Subscription-Key': subscriptionId }}); -const client = new QnAMakerClient(creds, endpoint); -client.endpointKeys.getKeys().then((result) => { - console.log("The result is:"); - console.log(result); + +msRestNodeAuth.interactiveLogin().then((creds) => { + const client = new QnAMakerRuntimeClient(creds, subscriptionId); + const kbId = "testkbId"; + const generateAnswerPayload: QnAMakerRuntimeModels.QueryDTO = { + qnaId: "testqnaId", + question: "testquestion", + top: 1, + userId: "testuserId", + isTest: true, + scoreThreshold: 1.01, + context: { + previousQnaId: "testpreviousQnaId", + previousUserQuery: "testpreviousUserQuery" + }, + strictFilters: [{ + name: "testname", + value: "testvalue" + }] + }; + client.runtime.generateAnswer(kbId, generateAnswerPayload).then((result) => { + console.log("The result is:"); + console.log(result); + }); }).catch((err) => { console.error(err); }); ``` -#### browser - Authentication, client creation and getKeys endpointKeys as an example written in JavaScript. +#### browser - Authentication, client creation and generateAnswer runtime as an example written in JavaScript. + +##### Install @azure/ms-rest-browserauth + +```bash +npm install @azure/ms-rest-browserauth +``` ##### Sample code +See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. + - index.html ```html @@ -50,15 +82,40 @@ client.endpointKeys.getKeys().then((result) => { @@ -69,3 +126,5 @@ client.endpointKeys.getKeys().then((result) => { ## Related projects - [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/cognitiveservices/cognitiveservices-qnamaker/README.png) diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/package.json b/sdk/cognitiveservices/cognitiveservices-qnamaker/package.json index 86831bce930f..29002b067abd 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/package.json +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/package.json @@ -1,11 +1,11 @@ { "name": "@azure/cognitiveservices-qnamaker", "author": "Microsoft Corporation", - "description": "QnAMakerClient Library with typescript type definitions for node.js and browser.", + "description": "QnAMakerRuntimeClient Library with typescript type definitions for node.js and browser.", "version": "2.0.0", "dependencies": { - "@azure/ms-rest-js": "^1.8.4", - "tslib": "^1.9.3" + "@azure/ms-rest-js": "^2.0.3", + "tslib": "^1.10.0" }, "keywords": [ "node", @@ -16,8 +16,8 @@ ], "license": "MIT", "main": "./dist/cognitiveservices-qnamaker.js", - "module": "./esm/qnAMakerClient.js", - "types": "./esm/qnAMakerClient.d.ts", + "module": "./esm/qnAMakerRuntimeClient.js", + "types": "./esm/qnAMakerRuntimeClient.d.ts", "devDependencies": { "typescript": "^3.1.1", "rollup": "^0.66.2", @@ -25,13 +25,13 @@ "rollup-plugin-sourcemaps": "^0.4.2", "uglify-js": "^3.4.9" }, - "homepage": "https://github.com/azure/azure-sdk-for-js/tree/master/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" + "url": "https://github.com/Azure/azure-sdk-for-js.git" }, "bugs": { - "url": "https://github.com/azure/azure-sdk-for-js/issues" + "url": "https://github.com/Azure/azure-sdk-for-js/issues" }, "files": [ "dist/**/*.js", diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/rollup.config.js b/sdk/cognitiveservices/cognitiveservices-qnamaker/rollup.config.js index c091ab62c00c..dd6db540ebd8 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/rollup.config.js +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/rollup.config.js @@ -6,7 +6,7 @@ import sourcemaps from "rollup-plugin-sourcemaps"; * @type {rollup.RollupFileOptions} */ const config = { - input: "./esm/qnAMakerClient.js", + input: "./esm/qnAMakerRuntimeClient.js", external: [ "@azure/ms-rest-js", "@azure/ms-rest-azure-js" diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/endpointSettingsMappers.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/endpointSettingsMappers.ts new file mode 100644 index 000000000000..41a5e8575e4f --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/endpointSettingsMappers.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export { + ActiveLearningSettingsDTO, + EndpointSettingsDTO, + EndpointSettingsDTOActiveLearning, + ErrorModel, + ErrorResponse, + ErrorResponseError, + InnerErrorModel +} from "../models/mappers"; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/index.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/index.ts index 540a6c146fca..52fc772e480a 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/index.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/index.ts @@ -10,200 +10,39 @@ import * as msRest from "@azure/ms-rest-js"; /** - * Input to create KB. - */ -export interface CreateKbInputDTO { - /** - * List of QNA to be added to the index. Ids are generated by the service and should be omitted. - */ - qnaList?: QnADTO[]; - /** - * List of URLs to be added to knowledgebase. - */ - urls?: string[]; - /** - * List of files to be added to knowledgebase. - */ - files?: FileDTO[]; -} - -/** - * An instance of CreateKbInputDTO for add operation - */ -export interface UpdateKbOperationDTOAdd extends CreateKbInputDTO { -} - -/** - * PATCH body schema of Delete Operation in UpdateKb - */ -export interface DeleteKbContentsDTO { - /** - * List of Qna Ids to be deleted - */ - ids?: number[]; - /** - * List of sources to be deleted from knowledgebase. - */ - sources?: string[]; -} - -/** - * An instance of DeleteKbContentsDTO for delete Operation - */ -export interface UpdateKbOperationDTODelete extends DeleteKbContentsDTO { -} - -/** - * PATCH body schema for Update operation in Update Kb - */ -export interface UpdateKbContentsDTO { - /** - * Friendly name for the knowledgebase. - */ - name?: string; - /** - * List of Q-A (UpdateQnaDTO) to be added to the knowledgebase. - */ - qnaList?: UpdateQnaDTO[]; - /** - * List of existing URLs to be refreshed. The content will be extracted again and re-indexed. - */ - urls?: string[]; -} - -/** - * An instance of UpdateKbContentsDTO for Update Operation - */ -export interface UpdateKbOperationDTOUpdate extends UpdateKbContentsDTO { -} - -/** - * Contains list of QnAs to be updated - */ -export interface UpdateKbOperationDTO { - /** - * An instance of CreateKbInputDTO for add operation - */ - add?: UpdateKbOperationDTOAdd; - /** - * An instance of DeleteKbContentsDTO for delete Operation - */ - deleteProperty?: UpdateKbOperationDTODelete; - /** - * An instance of UpdateKbContentsDTO for Update Operation - */ - update?: UpdateKbOperationDTOUpdate; -} - -/** - * PATCH Body schema for Update Kb which contains list of questions to be added and deleted - */ -export interface UpdateQuestionsDTO { - /** - * List of questions to be added - */ - add?: string[]; - /** - * List of questions to be deleted. - */ - deleteProperty?: string[]; -} - -/** - * List of questions associated with the answer. - */ -export interface UpdateQnaDTOQuestions extends UpdateQuestionsDTO { -} - -/** - * PATCH Body schema to represent list of Metadata to be updated + * Name - value pair of metadata. */ -export interface UpdateMetadataDTO { +export interface MetadataDTO { /** - * List of Metadata associated with answer to be deleted + * Metadata name. */ - deleteProperty?: MetadataDTO[]; + name: string; /** - * List of metadata associated with answer to be added + * Metadata value. */ - add?: MetadataDTO[]; -} - -/** - * List of metadata associated with the answer to be updated - */ -export interface UpdateQnaDTOMetadata extends UpdateMetadataDTO { + value: string; } /** - * Update Body schema to represent context to be updated + * Context associated with Qna. */ -export interface UpdateContextDTO { - /** - * List of prompts associated with qna to be deleted - */ - promptsToDelete?: number[]; - /** - * List of prompts to be added to the qna. - */ - promptsToAdd?: PromptDTO[]; +export interface ContextDTO { /** * To mark if a prompt is relevant only with a previous question or not. * true - Do not include this QnA as search result for queries without context * false - ignores context and includes this QnA in search result */ isContextOnly?: boolean; -} - -/** - * Context associated with Qna to be updated. - */ -export interface UpdateQnaDTOContext extends UpdateContextDTO { -} - -/** - * PATCH Body schema for Update Qna List - */ -export interface UpdateQnaDTO { - /** - * Unique id for the Q-A - */ - id?: number; - /** - * Answer text - */ - answer?: string; /** - * Source from which Q-A was indexed. eg. - * https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs - */ - source?: string; - /** - * List of questions associated with the answer. - */ - questions?: UpdateQnaDTOQuestions; - /** - * List of metadata associated with the answer to be updated - */ - metadata?: UpdateQnaDTOMetadata; - /** - * Context associated with Qna to be updated. + * List of prompts associated with the answer. */ - context?: UpdateQnaDTOContext; + prompts?: PromptDTO[]; } /** - * Name - value pair of metadata. + * Context of a QnA */ -export interface MetadataDTO { - /** - * Metadata name. - */ - name: string; - /** - * Metadata value. - */ - value: string; +export interface QnADTOContext extends ContextDTO { } /** @@ -265,86 +104,6 @@ export interface PromptDTO { displayText?: string; } -/** - * Context associated with Qna. - */ -export interface ContextDTO { - /** - * To mark if a prompt is relevant only with a previous question or not. - * true - Do not include this QnA as search result for queries without context - * false - ignores context and includes this QnA in search result - */ - isContextOnly?: boolean; - /** - * List of prompts associated with the answer. - */ - prompts?: PromptDTO[]; -} - -/** - * Context of a QnA - */ -export interface QnADTOContext extends ContextDTO { -} - -/** - * DTO to hold details of uploaded files. - */ -export interface FileDTO { - /** - * File name. Supported file types are ".tsv", ".pdf", ".txt", ".docx", ".xlsx". - */ - fileName: string; - /** - * Public URI of the file. - */ - fileUri: string; -} - -/** - * List of QnADTO - */ -export interface QnADocumentsDTO { - /** - * List of answers. - */ - qnaDocuments?: QnADTO[]; -} - -/** - * Post body schema for CreateKb operation. - */ -export interface CreateKbDTO { - /** - * Friendly name for the knowledgebase. - */ - name: string; - /** - * List of Q-A (QnADTO) to be added to the knowledgebase. Q-A Ids are assigned by the service and - * should be omitted. - */ - qnaList?: QnADTO[]; - /** - * List of URLs to be used for extracting Q-A. - */ - urls?: string[]; - /** - * List of files from which to Extract Q-A. - */ - files?: FileDTO[]; -} - -/** - * Post body schema for Replace KB operation. - */ -export interface ReplaceKbDTO { - /** - * List of Q-A (QnADTO) to be added to the knowledgebase. Q-A Ids are assigned by the service and - * should be omitted. - */ - qnAList: QnADTO[]; -} - /** * The error object. As per Microsoft One API guidelines - * https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. @@ -409,367 +168,159 @@ export interface InnerErrorModel { } /** - * Record to track long running operation. + * Context object with previous QnA's information. */ -export interface Operation { - /** - * Operation state. Possible values include: 'Failed', 'NotStarted', 'Running', 'Succeeded' - */ - operationState?: OperationStateType; +export interface QueryContextDTO { /** - * Timestamp when the operation was created. + * Previous QnA Id - qnaId of the top result. */ - createdTimestamp?: string; + previousQnaId?: string; /** - * Timestamp when the current state was entered. + * Previous user query. */ - lastActionTimestamp?: string; - /** - * Relative URI to the target resource location for completed resources. - */ - resourceLocation?: string; - /** - * User Id - */ - userId?: string; - /** - * Operation Id. - */ - operationId?: string; - /** - * Error details in case of failures. - */ - errorResponse?: ErrorResponse; + previousUserQuery?: string; } /** - * Response schema for CreateKb operation. + * Context object with previous QnA's information. */ -export interface KnowledgebaseDTO { - /** - * Unique id that identifies a knowledgebase. - */ - id?: string; +export interface QueryDTOContext extends QueryContextDTO { +} + +/** + * POST body schema to query the knowledgebase. + */ +export interface QueryDTO { /** - * URL host name at which the knowledgebase is hosted. + * Exact qnaId to fetch from the knowledgebase, this field takes priority over question. */ - hostName?: string; + qnaId?: string; /** - * Time stamp at which the knowledgebase was last accessed (UTC). + * User question to query against the knowledge base. */ - lastAccessedTimestamp?: string; + question?: string; /** - * Time stamp at which the knowledgebase was last modified (UTC). + * Max number of answers to be returned for the question. */ - lastChangedTimestamp?: string; + top?: number; /** - * Time stamp at which the knowledgebase was last published (UTC). + * Unique identifier for the user. */ - lastPublishedTimestamp?: string; + userId?: string; /** - * Friendly name of the knowledgebase. + * Query against the test index. */ - name?: string; + isTest?: boolean; /** - * User who created / owns the knowledgebase. + * Threshold for answers returned based on score. */ - userId?: string; + scoreThreshold?: number; /** - * URL sources from which Q-A were extracted and added to the knowledgebase. + * Context object with previous QnA's information. */ - urls?: string[]; + context?: QueryDTOContext; /** - * Custom sources from which Q-A were extracted or explicitly added to the knowledgebase. + * Find only answers that contain these metadata. */ - sources?: string[]; + strictFilters?: MetadataDTO[]; } /** - * Collection of knowledgebases owned by a user. + * Context object of the QnA */ -export interface KnowledgebasesDTO { - /** - * Collection of knowledgebase records. - */ - knowledgebases?: KnowledgebaseDTO[]; +export interface QnASearchResultContext extends ContextDTO { } /** - * Collection of words that are synonyms. + * Represents Search Result. */ -export interface AlterationsDTO { +export interface QnASearchResult { /** - * Words that are synonymous with each other. + * List of questions. */ - alterations: string[]; -} - -/** - * Collection of word alterations. - */ -export interface WordAlterationsDTO { + questions?: string[]; /** - * Collection of word alterations. + * Answer. */ - wordAlterations: AlterationsDTO[]; -} - -/** - * Schema for EndpointKeys generate/refresh operations. - */ -export interface EndpointKeysDTO { + answer?: string; /** - * Primary Access Key. + * Search result score. */ - primaryEndpointKey?: string; + score?: number; /** - * Secondary Access Key. + * Id of the QnA result. */ - secondaryEndpointKey?: string; + id?: number; /** - * Current version of runtime. + * Source of QnA result. */ - installedVersion?: string; + source?: string; /** - * Latest version of runtime. + * List of metadata. */ - lastStableVersion?: string; -} - -/** - * Defines headers for GetDetails operation. - */ -export interface OperationsGetDetailsHeaders { + metadata?: MetadataDTO[]; /** - * Indicates how long the client should wait before sending a follow up request. The header will - * be present only if the operation is running or has not started yet. + * Context object of the QnA */ - retryAfter: number; + context?: QnASearchResultContext; } /** - * Defines headers for Update operation. + * Represents List of Question Answers. */ -export interface KnowledgebaseUpdateHeaders { +export interface QnASearchResultList { /** - * Relative URI to the target location of the asynchronous operation. Client should poll this - * resource to get status of the operation. + * Represents Search Result list. */ - location: string; + answers?: QnASearchResult[]; } /** - * Defines values for KnowledgebaseEnvironmentType. - * Possible values include: 'Prod', 'Test' - * @readonly - * @enum {string} - */ -export type KnowledgebaseEnvironmentType = 'Prod' | 'Test'; - -/** - * Defines values for ErrorCodeType. - * Possible values include: 'BadArgument', 'Forbidden', 'NotFound', 'KbNotFound', 'Unauthorized', - * 'Unspecified', 'EndpointKeysError', 'QuotaExceeded', 'QnaRuntimeError', 'SKULimitExceeded', - * 'OperationNotFound', 'ServiceError', 'ValidationFailure', 'ExtractionFailure' - * @readonly - * @enum {string} + * Active learning feedback record. */ -export type ErrorCodeType = 'BadArgument' | 'Forbidden' | 'NotFound' | 'KbNotFound' | 'Unauthorized' | 'Unspecified' | 'EndpointKeysError' | 'QuotaExceeded' | 'QnaRuntimeError' | 'SKULimitExceeded' | 'OperationNotFound' | 'ServiceError' | 'ValidationFailure' | 'ExtractionFailure'; - -/** - * Defines values for OperationStateType. - * Possible values include: 'Failed', 'NotStarted', 'Running', 'Succeeded' - * @readonly - * @enum {string} - */ -export type OperationStateType = 'Failed' | 'NotStarted' | 'Running' | 'Succeeded'; - -/** - * Defines values for EnvironmentType. - * Possible values include: 'Prod', 'Test' - * @readonly - * @enum {string} - */ -export type EnvironmentType = 'Prod' | 'Test'; - -/** - * Contains response data for the getKeys operation. - */ -export type EndpointKeysGetKeysResponse = EndpointKeysDTO & { - /** - * 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: EndpointKeysDTO; - }; -}; - -/** - * Contains response data for the refreshKeys operation. - */ -export type EndpointKeysRefreshKeysResponse = EndpointKeysDTO & { - /** - * 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: EndpointKeysDTO; - }; -}; - -/** - * Contains response data for the get operation. - */ -export type AlterationsGetResponse = WordAlterationsDTO & { +export interface FeedbackRecordDTO { /** - * The underlying HTTP response. + * Unique identifier for the user. */ - _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. - */ -export type KnowledgebaseListAllResponse = KnowledgebasesDTO & { - /** - * 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: KnowledgebasesDTO; - }; -}; - -/** - * Contains response data for the getDetails operation. - */ -export type KnowledgebaseGetDetailsResponse = KnowledgebaseDTO & { + userId?: string; /** - * The underlying HTTP response. + * The suggested question being provided as feedback. */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: KnowledgebaseDTO; - }; -}; - -/** - * Contains response data for the update operation. - */ -export type KnowledgebaseUpdateResponse = Operation & KnowledgebaseUpdateHeaders & { + userQuestion?: string; /** - * The underlying HTTP response. + * The qnaId for which the suggested question is provided as feedback. */ - _response: msRest.HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: KnowledgebaseUpdateHeaders; - - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: Operation; - }; -}; + qnaId?: number; +} /** - * Contains response data for the create operation. + * Active learning feedback records. */ -export type KnowledgebaseCreateResponse = Operation & { +export interface FeedbackRecordsDTO { /** - * The underlying HTTP response. + * List of feedback records. */ - _response: msRest.HttpResponse & { - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * The response body as parsed JSON or XML - */ - parsedBody: Operation; - }; -}; + feedbackRecords?: FeedbackRecordDTO[]; +} /** - * Contains response data for the download operation. + * Defines values for ErrorCodeType. + * Possible values include: 'BadArgument', 'Forbidden', 'NotFound', 'KbNotFound', 'Unauthorized', + * 'Unspecified', 'EndpointKeysError', 'QuotaExceeded', 'QnaRuntimeError', 'SKULimitExceeded', + * 'OperationNotFound', 'ServiceError', 'ValidationFailure', 'ExtractionFailure' + * @readonly + * @enum {string} */ -export type KnowledgebaseDownloadResponse = QnADocumentsDTO & { - /** - * 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: QnADocumentsDTO; - }; -}; +export type ErrorCodeType = 'BadArgument' | 'Forbidden' | 'NotFound' | 'KbNotFound' | 'Unauthorized' | 'Unspecified' | 'EndpointKeysError' | 'QuotaExceeded' | 'QnaRuntimeError' | 'SKULimitExceeded' | 'OperationNotFound' | 'ServiceError' | 'ValidationFailure' | 'ExtractionFailure'; /** - * Contains response data for the getDetails operation. + * Contains response data for the generateAnswer operation. */ -export type OperationsGetDetailsResponse = Operation & OperationsGetDetailsHeaders & { +export type RuntimeGenerateAnswerResponse = QnASearchResultList & { /** * The underlying HTTP response. */ _response: msRest.HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: OperationsGetDetailsHeaders; - /** * The response body as text (string format) */ @@ -778,6 +329,6 @@ export type OperationsGetDetailsResponse = Operation & OperationsGetDetailsHeade /** * The response body as parsed JSON or XML */ - parsedBody: Operation; + parsedBody: QnASearchResultList; }; }; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/mappers.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/mappers.ts index ac4a6e0de483..4a7b79972392 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/mappers.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/mappers.ts @@ -9,380 +9,6 @@ import * as msRest from "@azure/ms-rest-js"; -export const CreateKbInputDTO: msRest.CompositeMapper = { - serializedName: "CreateKbInputDTO", - type: { - name: "Composite", - className: "CreateKbInputDTO", - modelProperties: { - qnaList: { - serializedName: "qnaList", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "QnADTO" - } - } - } - }, - urls: { - serializedName: "urls", - type: { - name: "Sequence", - element: { - type: { - name: "String" - } - } - } - }, - files: { - serializedName: "files", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "FileDTO" - } - } - } - } - } - } -}; - -export const UpdateKbOperationDTOAdd: msRest.CompositeMapper = { - serializedName: "UpdateKbOperationDTO_add", - type: { - name: "Composite", - className: "UpdateKbOperationDTOAdd", - modelProperties: { - ...CreateKbInputDTO.type.modelProperties - } - } -}; - -export const DeleteKbContentsDTO: msRest.CompositeMapper = { - serializedName: "DeleteKbContentsDTO", - type: { - name: "Composite", - className: "DeleteKbContentsDTO", - modelProperties: { - ids: { - serializedName: "ids", - type: { - name: "Sequence", - element: { - type: { - name: "Number" - } - } - } - }, - sources: { - serializedName: "sources", - type: { - name: "Sequence", - element: { - type: { - name: "String" - } - } - } - } - } - } -}; - -export const UpdateKbOperationDTODelete: msRest.CompositeMapper = { - serializedName: "UpdateKbOperationDTO_delete", - type: { - name: "Composite", - className: "UpdateKbOperationDTODelete", - modelProperties: { - ...DeleteKbContentsDTO.type.modelProperties - } - } -}; - -export const UpdateKbContentsDTO: msRest.CompositeMapper = { - serializedName: "UpdateKbContentsDTO", - type: { - name: "Composite", - className: "UpdateKbContentsDTO", - modelProperties: { - name: { - serializedName: "name", - type: { - name: "String" - } - }, - qnaList: { - serializedName: "qnaList", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "UpdateQnaDTO" - } - } - } - }, - urls: { - serializedName: "urls", - type: { - name: "Sequence", - element: { - type: { - name: "String" - } - } - } - } - } - } -}; - -export const UpdateKbOperationDTOUpdate: msRest.CompositeMapper = { - serializedName: "UpdateKbOperationDTO_update", - type: { - name: "Composite", - className: "UpdateKbOperationDTOUpdate", - modelProperties: { - ...UpdateKbContentsDTO.type.modelProperties - } - } -}; - -export const UpdateKbOperationDTO: msRest.CompositeMapper = { - serializedName: "UpdateKbOperationDTO", - type: { - name: "Composite", - className: "UpdateKbOperationDTO", - modelProperties: { - add: { - serializedName: "add", - type: { - name: "Composite", - className: "UpdateKbOperationDTOAdd" - } - }, - deleteProperty: { - serializedName: "delete", - type: { - name: "Composite", - className: "UpdateKbOperationDTODelete" - } - }, - update: { - serializedName: "update", - type: { - name: "Composite", - className: "UpdateKbOperationDTOUpdate" - } - } - } - } -}; - -export const UpdateQuestionsDTO: msRest.CompositeMapper = { - serializedName: "UpdateQuestionsDTO", - type: { - name: "Composite", - className: "UpdateQuestionsDTO", - modelProperties: { - add: { - serializedName: "add", - type: { - name: "Sequence", - element: { - type: { - name: "String" - } - } - } - }, - deleteProperty: { - serializedName: "delete", - type: { - name: "Sequence", - element: { - type: { - name: "String" - } - } - } - } - } - } -}; - -export const UpdateQnaDTOQuestions: msRest.CompositeMapper = { - serializedName: "UpdateQnaDTO_questions", - type: { - name: "Composite", - className: "UpdateQnaDTOQuestions", - modelProperties: { - ...UpdateQuestionsDTO.type.modelProperties - } - } -}; - -export const UpdateMetadataDTO: msRest.CompositeMapper = { - serializedName: "UpdateMetadataDTO", - type: { - name: "Composite", - className: "UpdateMetadataDTO", - modelProperties: { - deleteProperty: { - serializedName: "delete", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "MetadataDTO" - } - } - } - }, - add: { - serializedName: "add", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "MetadataDTO" - } - } - } - } - } - } -}; - -export const UpdateQnaDTOMetadata: msRest.CompositeMapper = { - serializedName: "UpdateQnaDTO_metadata", - type: { - name: "Composite", - className: "UpdateQnaDTOMetadata", - modelProperties: { - ...UpdateMetadataDTO.type.modelProperties - } - } -}; - -export const UpdateContextDTO: msRest.CompositeMapper = { - serializedName: "UpdateContextDTO", - type: { - name: "Composite", - className: "UpdateContextDTO", - modelProperties: { - promptsToDelete: { - serializedName: "promptsToDelete", - type: { - name: "Sequence", - element: { - type: { - name: "Number" - } - } - } - }, - promptsToAdd: { - serializedName: "promptsToAdd", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "PromptDTO" - } - } - } - }, - isContextOnly: { - serializedName: "isContextOnly", - type: { - name: "Boolean" - } - } - } - } -}; - -export const UpdateQnaDTOContext: msRest.CompositeMapper = { - serializedName: "UpdateQnaDTO_context", - type: { - name: "Composite", - className: "UpdateQnaDTOContext", - modelProperties: { - ...UpdateContextDTO.type.modelProperties - } - } -}; - -export const UpdateQnaDTO: msRest.CompositeMapper = { - serializedName: "UpdateQnaDTO", - type: { - name: "Composite", - className: "UpdateQnaDTO", - modelProperties: { - id: { - serializedName: "id", - constraints: { - InclusiveMaximum: 2147483647, - InclusiveMinimum: 0 - }, - type: { - name: "Number" - } - }, - answer: { - serializedName: "answer", - type: { - name: "String" - } - }, - source: { - serializedName: "source", - constraints: { - MaxLength: 300 - }, - type: { - name: "String" - } - }, - questions: { - serializedName: "questions", - type: { - name: "Composite", - className: "UpdateQnaDTOQuestions" - } - }, - metadata: { - serializedName: "metadata", - type: { - name: "Composite", - className: "UpdateQnaDTOMetadata" - } - }, - context: { - serializedName: "context", - type: { - name: "Composite", - className: "UpdateQnaDTOContext" - } - } - } - } -}; - export const MetadataDTO: msRest.CompositeMapper = { serializedName: "MetadataDTO", type: { @@ -406,193 +32,7 @@ export const MetadataDTO: msRest.CompositeMapper = { constraints: { MaxLength: 500, MinLength: 1 - }, - type: { - name: "String" - } - } - } - } -}; - -export const QnADTO: msRest.CompositeMapper = { - serializedName: "QnADTO", - type: { - name: "Composite", - className: "QnADTO", - modelProperties: { - id: { - serializedName: "id", - type: { - name: "Number" - } - }, - answer: { - required: true, - serializedName: "answer", - constraints: { - MaxLength: 25000, - MinLength: 1 - }, - type: { - name: "String" - } - }, - source: { - serializedName: "source", - constraints: { - MaxLength: 300 - }, - type: { - name: "String" - } - }, - questions: { - required: true, - serializedName: "questions", - type: { - name: "Sequence", - element: { - type: { - name: "String" - } - } - } - }, - metadata: { - serializedName: "metadata", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "MetadataDTO" - } - } - } - }, - context: { - serializedName: "context", - type: { - name: "Composite", - className: "QnADTOContext" - } - } - } - } -}; - -export const PromptDTOQna: msRest.CompositeMapper = { - serializedName: "PromptDTO_qna", - type: { - name: "Composite", - className: "PromptDTOQna", - modelProperties: { - ...QnADTO.type.modelProperties - } - } -}; - -export const PromptDTO: msRest.CompositeMapper = { - serializedName: "PromptDTO", - type: { - name: "Composite", - className: "PromptDTO", - modelProperties: { - displayOrder: { - serializedName: "displayOrder", - type: { - name: "Number" - } - }, - qnaId: { - serializedName: "qnaId", - type: { - name: "Number" - } - }, - qna: { - serializedName: "qna", - type: { - name: "Composite", - className: "PromptDTOQna" - } - }, - displayText: { - serializedName: "displayText", - constraints: { - MaxLength: 200 - }, - type: { - name: "String" - } - } - } - } -}; - -export const ContextDTO: msRest.CompositeMapper = { - serializedName: "ContextDTO", - type: { - name: "Composite", - className: "ContextDTO", - modelProperties: { - isContextOnly: { - serializedName: "isContextOnly", - type: { - name: "Boolean" - } - }, - prompts: { - serializedName: "prompts", - constraints: { - MaxItems: 20 - }, - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "PromptDTO" - } - } - } - } - } - } -}; - -export const QnADTOContext: msRest.CompositeMapper = { - serializedName: "QnADTO_context", - type: { - name: "Composite", - className: "QnADTOContext", - modelProperties: { - ...ContextDTO.type.modelProperties - } - } -}; - -export const FileDTO: msRest.CompositeMapper = { - serializedName: "FileDTO", - type: { - name: "Composite", - className: "FileDTO", - modelProperties: { - fileName: { - required: true, - serializedName: "fileName", - constraints: { - MaxLength: 200, - MinLength: 1 - }, - type: { - name: "String" - } - }, - fileUri: { - required: true, - serializedName: "fileUri", + }, type: { name: "String" } @@ -601,20 +41,29 @@ export const FileDTO: msRest.CompositeMapper = { } }; -export const QnADocumentsDTO: msRest.CompositeMapper = { - serializedName: "QnADocumentsDTO", +export const ContextDTO: msRest.CompositeMapper = { + serializedName: "ContextDTO", type: { name: "Composite", - className: "QnADocumentsDTO", + className: "ContextDTO", modelProperties: { - qnaDocuments: { - serializedName: "qnaDocuments", + isContextOnly: { + serializedName: "isContextOnly", + type: { + name: "Boolean" + } + }, + prompts: { + serializedName: "prompts", + constraints: { + MaxItems: 20 + }, type: { name: "Sequence", element: { type: { name: "Composite", - className: "QnADTO" + className: "PromptDTO" } } } @@ -623,37 +72,52 @@ export const QnADocumentsDTO: msRest.CompositeMapper = { } }; -export const CreateKbDTO: msRest.CompositeMapper = { - serializedName: "CreateKbDTO", +export const QnADTOContext: msRest.CompositeMapper = { + serializedName: "QnADTO_context", type: { name: "Composite", - className: "CreateKbDTO", + className: "QnADTOContext", modelProperties: { - name: { + ...ContextDTO.type.modelProperties + } + } +}; + +export const QnADTO: msRest.CompositeMapper = { + serializedName: "QnADTO", + type: { + name: "Composite", + className: "QnADTO", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "Number" + } + }, + answer: { required: true, - serializedName: "name", + serializedName: "answer", constraints: { - MaxLength: 100, + MaxLength: 25000, MinLength: 1 }, type: { name: "String" } }, - qnaList: { - serializedName: "qnaList", + source: { + serializedName: "source", + constraints: { + MaxLength: 300 + }, type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "QnADTO" - } - } + name: "String" } }, - urls: { - serializedName: "urls", + questions: { + required: true, + serializedName: "questions", type: { name: "Sequence", element: { @@ -663,39 +127,72 @@ export const CreateKbDTO: msRest.CompositeMapper = { } } }, - files: { - serializedName: "files", + metadata: { + serializedName: "metadata", type: { name: "Sequence", element: { type: { name: "Composite", - className: "FileDTO" + className: "MetadataDTO" } } } + }, + context: { + serializedName: "context", + type: { + name: "Composite", + className: "QnADTOContext" + } } } } }; -export const ReplaceKbDTO: msRest.CompositeMapper = { - serializedName: "ReplaceKbDTO", +export const PromptDTOQna: msRest.CompositeMapper = { + serializedName: "PromptDTO_qna", type: { name: "Composite", - className: "ReplaceKbDTO", + className: "PromptDTOQna", modelProperties: { - qnAList: { - required: true, - serializedName: "qnAList", + ...QnADTO.type.modelProperties + } + } +}; + +export const PromptDTO: msRest.CompositeMapper = { + serializedName: "PromptDTO", + type: { + name: "Composite", + className: "PromptDTO", + modelProperties: { + displayOrder: { + serializedName: "displayOrder", type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "QnADTO" - } - } + name: "Number" + } + }, + qnaId: { + serializedName: "qnaId", + type: { + name: "Number" + } + }, + qna: { + serializedName: "qna", + type: { + name: "Composite", + className: "PromptDTOQna" + } + }, + displayText: { + serializedName: "displayText", + constraints: { + MaxLength: 200 + }, + type: { + name: "String" } } } @@ -801,125 +298,96 @@ export const InnerErrorModel: msRest.CompositeMapper = { } }; -export const Operation: msRest.CompositeMapper = { - serializedName: "Operation", +export const QueryContextDTO: msRest.CompositeMapper = { + serializedName: "QueryContextDTO", type: { name: "Composite", - className: "Operation", + className: "QueryContextDTO", modelProperties: { - operationState: { - serializedName: "operationState", - type: { - name: "String" - } - }, - createdTimestamp: { - serializedName: "createdTimestamp", - type: { - name: "String" - } - }, - lastActionTimestamp: { - serializedName: "lastActionTimestamp", - type: { - name: "String" - } - }, - resourceLocation: { - serializedName: "resourceLocation", - type: { - name: "String" - } - }, - userId: { - serializedName: "userId", + previousQnaId: { + serializedName: "previousQnaId", type: { name: "String" } }, - operationId: { - serializedName: "operationId", + previousUserQuery: { + serializedName: "previousUserQuery", type: { name: "String" } - }, - errorResponse: { - serializedName: "errorResponse", - type: { - name: "Composite", - className: "ErrorResponse" - } } } } }; -export const KnowledgebaseDTO: msRest.CompositeMapper = { - serializedName: "KnowledgebaseDTO", +export const QueryDTOContext: msRest.CompositeMapper = { + serializedName: "QueryDTO_context", type: { name: "Composite", - className: "KnowledgebaseDTO", + className: "QueryDTOContext", modelProperties: { - id: { - serializedName: "id", - type: { - name: "String" - } - }, - hostName: { - serializedName: "hostName", + ...QueryContextDTO.type.modelProperties + } + } +}; + +export const QueryDTO: msRest.CompositeMapper = { + serializedName: "QueryDTO", + type: { + name: "Composite", + className: "QueryDTO", + modelProperties: { + qnaId: { + serializedName: "qnaId", type: { name: "String" } }, - lastAccessedTimestamp: { - serializedName: "lastAccessedTimestamp", + question: { + serializedName: "question", type: { name: "String" } }, - lastChangedTimestamp: { - serializedName: "lastChangedTimestamp", + top: { + serializedName: "top", type: { - name: "String" + name: "Number" } }, - lastPublishedTimestamp: { - serializedName: "lastPublishedTimestamp", + userId: { + serializedName: "userId", type: { name: "String" } }, - name: { - serializedName: "name", + isTest: { + serializedName: "isTest", type: { - name: "String" + name: "Boolean" } }, - userId: { - serializedName: "userId", + scoreThreshold: { + serializedName: "scoreThreshold", type: { - name: "String" + name: "Number" } }, - urls: { - serializedName: "urls", + context: { + serializedName: "context", type: { - name: "Sequence", - element: { - type: { - name: "String" - } - } + name: "Composite", + className: "QueryDTOContext" } }, - sources: { - serializedName: "sources", + strictFilters: { + serializedName: "strictFilters", type: { name: "Sequence", element: { type: { - name: "String" + name: "Composite", + className: "MetadataDTO" } } } @@ -928,37 +396,25 @@ export const KnowledgebaseDTO: msRest.CompositeMapper = { } }; -export const KnowledgebasesDTO: msRest.CompositeMapper = { - serializedName: "KnowledgebasesDTO", +export const QnASearchResultContext: msRest.CompositeMapper = { + serializedName: "QnASearchResult_context", type: { name: "Composite", - className: "KnowledgebasesDTO", + className: "QnASearchResultContext", modelProperties: { - knowledgebases: { - serializedName: "knowledgebases", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "KnowledgebaseDTO" - } - } - } - } + ...ContextDTO.type.modelProperties } } }; -export const AlterationsDTO: msRest.CompositeMapper = { - serializedName: "AlterationsDTO", +export const QnASearchResult: msRest.CompositeMapper = { + serializedName: "QnASearchResult", type: { name: "Composite", - className: "AlterationsDTO", + className: "QnASearchResult", modelProperties: { - alterations: { - required: true, - serializedName: "alterations", + questions: { + serializedName: "questions", type: { name: "Sequence", element: { @@ -967,26 +423,68 @@ export const AlterationsDTO: msRest.CompositeMapper = { } } } + }, + 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" + } } } } }; -export const WordAlterationsDTO: msRest.CompositeMapper = { - serializedName: "WordAlterationsDTO", +export const QnASearchResultList: msRest.CompositeMapper = { + serializedName: "QnASearchResultList", type: { name: "Composite", - className: "WordAlterationsDTO", + className: "QnASearchResultList", modelProperties: { - wordAlterations: { - required: true, - serializedName: "wordAlterations", + answers: { + serializedName: "answers", type: { name: "Sequence", element: { type: { name: "Composite", - className: "AlterationsDTO" + className: "QnASearchResult" } } } @@ -995,48 +493,29 @@ export const WordAlterationsDTO: msRest.CompositeMapper = { } }; -export const EndpointKeysDTO: msRest.CompositeMapper = { - serializedName: "EndpointKeysDTO", +export const FeedbackRecordDTO: msRest.CompositeMapper = { + serializedName: "FeedbackRecordDTO", type: { name: "Composite", - className: "EndpointKeysDTO", + className: "FeedbackRecordDTO", modelProperties: { - primaryEndpointKey: { - serializedName: "primaryEndpointKey", - type: { - name: "String" - } - }, - secondaryEndpointKey: { - serializedName: "secondaryEndpointKey", + userId: { + serializedName: "userId", type: { name: "String" } }, - installedVersion: { - serializedName: "installedVersion", + userQuestion: { + serializedName: "userQuestion", + constraints: { + MaxLength: 1000 + }, type: { name: "String" } }, - lastStableVersion: { - serializedName: "lastStableVersion", - type: { - name: "String" - } - } - } - } -}; - -export const OperationsGetDetailsHeaders: msRest.CompositeMapper = { - serializedName: "operations-getdetails-headers", - type: { - name: "Composite", - className: "OperationsGetDetailsHeaders", - modelProperties: { - retryAfter: { - serializedName: "retryafter", + qnaId: { + serializedName: "qnaId", type: { name: "Number" } @@ -1045,16 +524,22 @@ export const OperationsGetDetailsHeaders: msRest.CompositeMapper = { } }; -export const KnowledgebaseUpdateHeaders: msRest.CompositeMapper = { - serializedName: "knowledgebase-update-headers", +export const FeedbackRecordsDTO: msRest.CompositeMapper = { + serializedName: "FeedbackRecordsDTO", type: { name: "Composite", - className: "KnowledgebaseUpdateHeaders", + className: "FeedbackRecordsDTO", modelProperties: { - location: { - serializedName: "location", + feedbackRecords: { + serializedName: "feedbackRecords", type: { - name: "String" + name: "Sequence", + element: { + type: { + name: "Composite", + className: "FeedbackRecordDTO" + } + } } } } diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/parameters.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/parameters.ts index 5ad11ee6c076..0a7961719ae1 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/parameters.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/parameters.ts @@ -10,29 +10,6 @@ import * as msRest from "@azure/ms-rest-js"; -export const endpoint: msRest.OperationURLParameter = { - parameterPath: "endpoint", - mapper: { - required: true, - serializedName: "Endpoint", - defaultValue: '', - type: { - name: "String" - } - }, - skipEncoding: true -}; -export const environment: msRest.OperationURLParameter = { - parameterPath: "environment", - mapper: { - required: true, - nullable: false, - serializedName: "environment", - type: { - name: "String" - } - } -}; export const kbId: msRest.OperationURLParameter = { parameterPath: "kbId", mapper: { @@ -44,25 +21,15 @@ export const kbId: msRest.OperationURLParameter = { } } }; -export const keyType: msRest.OperationURLParameter = { - parameterPath: "keyType", +export const runtimeEndpoint: msRest.OperationURLParameter = { + parameterPath: "runtimeEndpoint", mapper: { required: true, - nullable: false, - serializedName: "keyType", - type: { - name: "String" - } - } -}; -export const operationId: msRest.OperationURLParameter = { - parameterPath: "operationId", - mapper: { - required: true, - nullable: false, - serializedName: "operationId", + serializedName: "RuntimeEndpoint", + defaultValue: '', type: { name: "String" } - } + }, + skipEncoding: true }; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/runtimeMappers.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/runtimeMappers.ts new file mode 100644 index 000000000000..77bd13158d3b --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/runtimeMappers.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export { + ContextDTO, + ErrorModel, + ErrorResponse, + ErrorResponseError, + FeedbackRecordDTO, + FeedbackRecordsDTO, + InnerErrorModel, + MetadataDTO, + PromptDTO, + PromptDTOQna, + QnADTO, + QnADTOContext, + QnASearchResult, + QnASearchResultContext, + QnASearchResultList, + QueryContextDTO, + QueryDTO, + QueryDTOContext +} from "../models/mappers"; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/endpointSettings.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/endpointSettings.ts new file mode 100644 index 000000000000..9b21f50dbcdf --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/endpointSettings.ts @@ -0,0 +1,128 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; +import * as Models from "../models"; +import * as Mappers from "../models/endpointSettingsMappers"; +import * as Parameters from "../models/parameters"; +import { QnAMakerClientContext } from "../qnAMakerClientContext"; + +/** Class representing a EndpointSettings. */ +export class EndpointSettings { + private readonly client: QnAMakerClientContext; + + /** + * Create a EndpointSettings. + * @param {QnAMakerClientContext} client Reference to the service client. + */ + constructor(client: QnAMakerClientContext) { + this.client = client; + } + + /** + * @summary Gets endpoint settings for an endpoint. + * @param [options] The optional parameters + * @returns Promise + */ + getSettings(options?: msRest.RequestOptionsBase): Promise; + /** + * @param callback The callback + */ + getSettings(callback: msRest.ServiceCallback): void; + /** + * @param options The optional parameters + * @param callback The callback + */ + getSettings(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + getSettings(options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + options + }, + getSettingsOperationSpec, + callback) as Promise; + } + + /** + * @summary Updates endpoint settings for an endpoint. + * @param endpointSettingsPayload Post body of the request. + * @param [options] The optional parameters + * @returns Promise + */ + updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, options?: msRest.RequestOptionsBase): Promise; + /** + * @param endpointSettingsPayload Post body of the request. + * @param callback The callback + */ + updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, callback: msRest.ServiceCallback): void; + /** + * @param endpointSettingsPayload Post body of the request. + * @param options The optional parameters + * @param callback The callback + */ + updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.client.sendOperationRequest( + { + endpointSettingsPayload, + options + }, + updateSettingsOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const getSettingsOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "endpointSettings", + urlParameters: [ + Parameters.endpoint + ], + responses: { + 200: { + bodyMapper: Mappers.EndpointSettingsDTO + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; + +const updateSettingsOperationSpec: msRest.OperationSpec = { + httpMethod: "PATCH", + path: "endpointSettings", + urlParameters: [ + Parameters.endpoint + ], + requestBody: { + parameterPath: "endpointSettingsPayload", + mapper: { + ...Mappers.EndpointSettingsDTO, + required: true + } + }, + responses: { + 200: { + bodyMapper: { + serializedName: "parsedResponse", + type: { + name: "String" + } + } + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + serializer +}; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/index.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/index.ts index e46ec2db7f23..943e2f1af5f1 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/index.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/index.ts @@ -8,7 +8,4 @@ * regenerated. */ -export * from "./endpointKeys"; -export * from "./alterations"; -export * from "./knowledgebase"; -export * from "./operations"; +export * from "./runtime"; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/runtime.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/runtime.ts new file mode 100644 index 000000000000..7d6fcbff9c49 --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/runtime.ts @@ -0,0 +1,142 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; +import * as Models from "../models"; +import * as Mappers from "../models/runtimeMappers"; +import * as Parameters from "../models/parameters"; +import { QnAMakerRuntimeClientContext } from "../qnAMakerRuntimeClientContext"; + +/** Class representing a Runtime. */ +export class Runtime { + private readonly client: QnAMakerRuntimeClientContext; + + /** + * Create a Runtime. + * @param {QnAMakerRuntimeClientContext} client Reference to the service client. + */ + constructor(client: QnAMakerRuntimeClientContext) { + this.client = client; + } + + /** + * @summary GenerateAnswer call to query the knowledgebase. + * @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 the knowledgebase. + * @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 +const serializer = new msRest.Serializer(Mappers); +const generateAnswerOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "knowledgebases/{kbId}/generateAnswer", + urlParameters: [ + Parameters.runtimeEndpoint, + 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.runtimeEndpoint, + 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 ee10e56a80ad..bf1194ce9e10 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClient.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClient.ts @@ -16,6 +16,7 @@ import { QnAMakerClientContext } from "./qnAMakerClientContext"; class QnAMakerClient extends QnAMakerClientContext { // Operation groups + endpointSettings: operations.EndpointSettings; endpointKeys: operations.EndpointKeys; alterations: operations.Alterations; knowledgebase: operations.Knowledgebase; @@ -30,6 +31,7 @@ class QnAMakerClient extends QnAMakerClientContext { */ constructor(credentials: msRest.ServiceClientCredentials, endpoint: string, options?: msRest.ServiceClientOptions) { super(credentials, endpoint, options); + this.endpointSettings = new operations.EndpointSettings(this); this.endpointKeys = new operations.EndpointKeys(this); this.alterations = new operations.Alterations(this); this.knowledgebase = new operations.Knowledgebase(this); diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClientContext.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClientContext.ts index e76db2de129e..556970b3af33 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClientContext.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerClientContext.ts @@ -11,7 +11,7 @@ import * as msRest from "@azure/ms-rest-js"; const packageName = "@azure/cognitiveservices-qnamaker"; -const packageVersion = "1.0.0"; +const packageVersion = "2.0.0"; export class QnAMakerClientContext extends msRest.ServiceClient { endpoint: string; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerRuntimeClient.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerRuntimeClient.ts new file mode 100644 index 000000000000..693d97cd848e --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerRuntimeClient.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; +import * as Models from "./models"; +import * as Mappers from "./models/mappers"; +import * as operations from "./operations"; +import { QnAMakerRuntimeClientContext } from "./qnAMakerRuntimeClientContext"; + +class QnAMakerRuntimeClient extends QnAMakerRuntimeClientContext { + // Operation groups + runtime: operations.Runtime; + + /** + * Initializes a new instance of the QnAMakerRuntimeClient class. + * @param runtimeEndpoint QnA Maker App Service endpoint (for example: + * https://{qnaservice-hostname}.azurewebsites.net). + * @param credentials Subscription credentials which uniquely identify client subscription. + * @param [options] The parameter options + */ + constructor(credentials: msRest.ServiceClientCredentials, runtimeEndpoint: string, options?: msRest.ServiceClientOptions) { + super(credentials, runtimeEndpoint, options); + this.runtime = new operations.Runtime(this); + } +} + +// Operation Specifications + +export { + QnAMakerRuntimeClient, + QnAMakerRuntimeClientContext, + Models as QnAMakerRuntimeModels, + Mappers as QnAMakerRuntimeMappers +}; +export * from "./operations"; diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerRuntimeClientContext.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerRuntimeClientContext.ts new file mode 100644 index 000000000000..8b137e483a6a --- /dev/null +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/qnAMakerRuntimeClientContext.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; + +const packageName = "@azure/cognitiveservices-qnamaker"; +const packageVersion = "2.0.0"; + +export class QnAMakerRuntimeClientContext extends msRest.ServiceClient { + runtimeEndpoint: string; + credentials: msRest.ServiceClientCredentials; + + /** + * Initializes a new instance of the QnAMakerRuntimeClientContext class. + * @param runtimeEndpoint QnA Maker App Service endpoint (for example: + * https://{qnaservice-hostname}.azurewebsites.net). + * @param credentials Subscription credentials which uniquely identify client subscription. + * @param [options] The parameter options + */ + constructor(credentials: msRest.ServiceClientCredentials, runtimeEndpoint: string, options?: msRest.ServiceClientOptions) { + if (runtimeEndpoint == undefined) { + throw new Error("'runtimeEndpoint' cannot be null."); + } + if (credentials == undefined) { + throw new Error("'credentials' cannot be null."); + } + + if (!options) { + options = {}; + } + + if (!options.userAgent) { + const defaultUserAgent = msRest.getDefaultUserAgentValue(); + options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; + } + + super(credentials, options); + + this.baseUri = "{RuntimeEndpoint}/qnamaker"; + this.requestContentType = "application/json; charset=utf-8"; + this.runtimeEndpoint = runtimeEndpoint; + this.credentials = credentials; + } +} diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/tsconfig.json b/sdk/cognitiveservices/cognitiveservices-qnamaker/tsconfig.json index 87bbf5b5fa49..422b584abd5e 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/tsconfig.json +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/tsconfig.json @@ -9,7 +9,7 @@ "esModuleInterop": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, - "lib": ["es6"], + "lib": ["es6", "dom"], "declaration": true, "outDir": "./esm", "importHelpers": true