From 8220a9772407eacfc827bf53878b3f433cdd6559 Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Mon, 28 Sep 2020 20:33:39 +0000 Subject: [PATCH] Generated from 6717fba94e5cf9a954b650caf0f15b2880d102ef --- .../cognitiveservices-qnamaker/README.md | 124 ++- .../cognitiveservices-qnamaker/package.json | 6 +- .../rollup.config.js | 2 +- .../src/models/index.ts | 715 ++----------- .../src/models/mappers.ts | 983 ++++-------------- .../src/models/parameters.ts | 42 +- .../src/models/runtimeMappers.ts | 28 + .../src/operations/endpointSettings.ts | 21 +- .../src/operations/index.ts | 6 +- .../src/operations/runtime.ts | 142 +++ .../src/qnAMakerRuntimeClient.ts | 42 + .../src/qnAMakerRuntimeClientContext.ts | 51 + 12 files changed, 652 insertions(+), 1510 deletions(-) create mode 100644 sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/runtimeMappers.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 824eba6f559d..b7d962fc0f5e 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/README.md +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/README.md @@ -1,7 +1,6 @@ -## An isomorphic javascript sdk for - QnAMakerClient +## An isomorphic javascript sdk for - QnAMakerRuntimeClient -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 for QnAMakerRuntimeClient. ### Currently supported environments @@ -16,36 +15,54 @@ npm install @azure/cognitiveservices-qnamaker ### How to use -#### nodejs - Authentication, client creation and getSettings endpointSettings as an example written in TypeScript. +#### nodejs - Authentication, client creation and generateAnswer runtime as an example written in TypeScript. -##### Install @azure/ms-rest-azure-js +##### Install @azure/ms-rest-nodeauth +- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. ```bash -npm install @azure/ms-rest-azure-js +npm install @azure/ms-rest-nodeauth@"^3.0.0" ``` ##### Sample code -```javascript -const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js"); -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(); +```typescript +import * as msRest from "@azure/ms-rest-js"; +import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; +import { QnAMakerRuntimeClient, QnAMakerRuntimeModels, QnAMakerRuntimeMappers } from "@azure/cognitiveservices-qnamaker"; +const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; + +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" + }, + rankerType: "testrankerType", + strictFilters: [{ + name: "testname", + value: "testvalue" + }], + strictFiltersCompoundOperationType: "AND" + }; + 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 getSettings endpointSettings as an example written in JavaScript. +#### browser - Authentication, client creation and generateAnswer runtime as an example written in JavaScript. ##### Install @azure/ms-rest-browserauth @@ -58,34 +75,53 @@ npm install @azure/ms-rest-browserauth See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - index.html - ```html @azure/cognitiveservices-qnamaker sample + @@ -96,4 +132,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 9047c9c65574..20b827c75eb6 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/package.json +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/package.json @@ -1,7 +1,7 @@ { "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": "3.1.1", "dependencies": { "@azure/ms-rest-js": "^2.0.4", @@ -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.5.3", "rollup": "^1.18.0", diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/rollup.config.js b/sdk/cognitiveservices/cognitiveservices-qnamaker/rollup.config.js index aa740262d6cc..994e7edbf48f 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/index.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/index.ts index a8899db2a92b..8aa9cc560bf3 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/index.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/index.ts @@ -10,210 +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; - /** - * Enable hierarchical extraction of Q-A from files and urls. The value set during KB creation - * will be used if this field is not present. - */ - enableHierarchicalExtraction?: boolean; - /** - * Text string to be used as the answer in any Q-A which has no extracted answer from the - * document but has a hierarchy. Required when EnableHierarchicalExtraction field is set to True. - */ - defaultAnswerUsedForExtraction?: string; -} - -/** - * 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 { } /** @@ -275,100 +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[]; - /** - * Enable hierarchical extraction of Q-A from files and urls. Value to be considered False if - * this field is not present. - */ - enableHierarchicalExtraction?: boolean; - /** - * Text string to be used as the answer in any Q-A which has no extracted answer from the - * document but has a hierarchy. Required when EnableHierarchicalExtraction field is set to True. - */ - defaultAnswerUsedForExtraction?: string; - /** - * Language of the knowledgebase. - */ - language?: string; -} - -/** - * 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. @@ -433,183 +168,150 @@ 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. Optional parameter for telemetry. For more information, refer + * Analytics and + * Telemetry. */ - 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. + * Optional field. Set to 'QuestionOnly' for using a question only Ranker. */ - sources?: string[]; -} - -/** - * Collection of knowledgebases owned by a user. - */ -export interface KnowledgebasesDTO { + rankerType?: string; /** - * Collection of knowledgebase records. + * Find only answers that contain these metadata. */ - knowledgebases?: KnowledgebaseDTO[]; -} - -/** - * Active Learning settings of the endpoint. - */ -export interface ActiveLearningSettingsDTO { + strictFilters?: MetadataDTO[]; /** - * True/False string providing Active Learning + * Optional field. Set to OR for using OR as Operation for Strict Filters. Possible values + * include: 'AND', 'OR' */ - enable?: string; + strictFiltersCompoundOperationType?: StrictFiltersCompoundOperationType; } /** - * Active Learning settings of the endpoint. + * Context object of the QnA */ -export interface EndpointSettingsDTOActiveLearning extends ActiveLearningSettingsDTO { +export interface QnASearchResultContext extends ContextDTO { } /** - * Endpoint settings. + * Represents Search Result. */ -export interface EndpointSettingsDTO { +export interface QnASearchResult { /** - * Active Learning settings of the endpoint. + * List of questions. */ - activeLearning?: EndpointSettingsDTOActiveLearning; -} - -/** - * Collection of words that are synonyms. - */ -export interface AlterationsDTO { + questions?: string[]; /** - * Words that are synonymous with each other. + * Answer. */ - alterations: string[]; -} - -/** - * Collection of word alterations. - */ -export interface WordAlterationsDTO { + answer?: string; /** - * Collection of word alterations. + * Search result score. */ - wordAlterations: AlterationsDTO[]; -} - -/** - * Schema for EndpointKeys generate/refresh operations. - */ -export interface EndpointKeysDTO { + score?: number; /** - * Primary Access Key. + * Id of the QnA result. */ - primaryEndpointKey?: string; + id?: number; /** - * Secondary Access Key. + * Source of QnA result. */ - secondaryEndpointKey?: string; + source?: string; /** - * Current version of runtime. + * List of metadata. */ - installedVersion?: string; + metadata?: MetadataDTO[]; /** - * Latest version of runtime. + * Context object of the QnA */ - lastStableVersion?: string; + context?: QnASearchResultContext; +} + +/** + * Represents List of Question Answers. + */ +export interface QnASearchResultList { /** - * Language setting of runtime. + * Represents Search Result list. */ - language?: string; + answers?: QnASearchResult[]; } /** - * Defines headers for GetDetails operation. + * Active learning feedback record. */ -export interface OperationsGetDetailsHeaders { +export interface FeedbackRecordDTO { /** - * 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. + * Unique identifier for the user. */ - retryAfter: number; + userId?: string; + /** + * The suggested question being provided as feedback. + */ + userQuestion?: string; + /** + * The qnaId for which the suggested question is provided as feedback. + */ + qnaId?: number; } /** - * Defines headers for Update operation. + * Active learning feedback records. */ -export interface KnowledgebaseUpdateHeaders { +export interface FeedbackRecordsDTO { /** - * Relative URI to the target location of the asynchronous operation. Client should poll this - * resource to get status of the operation. + * List of feedback records. */ - location: string; + feedbackRecords?: FeedbackRecordDTO[]; } /** @@ -623,50 +325,17 @@ export interface KnowledgebaseUpdateHeaders { 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' + * Defines values for StrictFiltersCompoundOperationType. + * Possible values include: 'AND', 'OR' * @readonly * @enum {string} */ -export type OperationStateType = 'Failed' | 'NotStarted' | 'Running' | 'Succeeded'; +export type StrictFiltersCompoundOperationType = 'AND' | 'OR'; /** - * Defines values for EnvironmentType. - * Possible values include: 'Prod', 'Test' - * @readonly - * @enum {string} + * Contains response data for the generateAnswer operation. */ -export type EnvironmentType = 'Prod' | 'Test'; - -/** - * Contains response data for the getSettings operation. - */ -export type EndpointSettingsGetSettingsResponse = EndpointSettingsDTO & { - /** - * 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: EndpointSettingsDTO; - }; -}; - -/** - * Contains response data for the updateSettings operation. - */ -export type EndpointSettingsUpdateSettingsResponse = { - /** - * The parsed response body. - */ - body: string; - +export type RuntimeGenerateAnswerResponse = QnASearchResultList & { /** * The underlying HTTP response. */ @@ -679,196 +348,6 @@ export type EndpointSettingsUpdateSettingsResponse = { /** * The response body as parsed JSON or XML */ - parsedBody: string; - }; -}; - -/** - * 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 & { - /** - * 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. - */ -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 & { - /** - * 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: KnowledgebaseDTO; - }; -}; - -/** - * Contains response data for the update operation. - */ -export type KnowledgebaseUpdateResponse = Operation & KnowledgebaseUpdateHeaders & { - /** - * The underlying HTTP response. - */ - _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; - }; -}; - -/** - * Contains response data for the create operation. - */ -export type KnowledgebaseCreateResponse = Operation & { - /** - * 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: Operation; - }; -}; - -/** - * Contains response data for the download operation. - */ -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; - }; -}; - -/** - * Contains response data for the getDetails operation. - */ -export type OperationsGetDetailsResponse = Operation & OperationsGetDetailsHeaders & { - /** - * The underlying HTTP response. - */ - _response: msRest.HttpResponse & { - /** - * The parsed HTTP response headers. - */ - parsedHeaders: OperationsGetDetailsHeaders; - - /** - * The response body as text (string format) - */ - bodyAsText: string; - - /** - * 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 6322d37f7e6a..0b94a70a762e 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/mappers.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/mappers.ts @@ -9,396 +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" - } - }, - enableHierarchicalExtraction: { - serializedName: "enableHierarchicalExtraction", - type: { - name: "Boolean" - } - }, - defaultAnswerUsedForExtraction: { - serializedName: "defaultAnswerUsedForExtraction", - constraints: { - MaxLength: 300, - MinLength: 1 - }, - type: { - name: "String" - } - } - } - } -}; - -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: { @@ -431,122 +41,6 @@ export const MetadataDTO: msRest.CompositeMapper = { } }; -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: { @@ -589,87 +83,41 @@ export const QnADTOContext: msRest.CompositeMapper = { } }; -export const FileDTO: msRest.CompositeMapper = { - serializedName: "FileDTO", +export const QnADTO: msRest.CompositeMapper = { + serializedName: "QnADTO", type: { name: "Composite", - className: "FileDTO", + className: "QnADTO", modelProperties: { - fileName: { - required: true, - serializedName: "fileName", - constraints: { - MaxLength: 200, - MinLength: 1 - }, + id: { + serializedName: "id", type: { - name: "String" + name: "Number" } }, - fileUri: { - required: true, - serializedName: "fileUri", - type: { - name: "String" - } - } - } - } -}; - -export const QnADocumentsDTO: msRest.CompositeMapper = { - serializedName: "QnADocumentsDTO", - type: { - name: "Composite", - className: "QnADocumentsDTO", - modelProperties: { - qnaDocuments: { - serializedName: "qnaDocuments", - type: { - name: "Sequence", - element: { - type: { - name: "Composite", - className: "QnADTO" - } - } - } - } - } - } -}; - -export const CreateKbDTO: msRest.CompositeMapper = { - serializedName: "CreateKbDTO", - type: { - name: "Composite", - className: "CreateKbDTO", - modelProperties: { - name: { + 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: { @@ -679,65 +127,72 @@ export const CreateKbDTO: msRest.CompositeMapper = { } } }, - files: { - serializedName: "files", + metadata: { + serializedName: "metadata", type: { name: "Sequence", element: { type: { name: "Composite", - className: "FileDTO" + className: "MetadataDTO" } } } }, - enableHierarchicalExtraction: { - serializedName: "enableHierarchicalExtraction", - type: { - name: "Boolean" - } - }, - defaultAnswerUsedForExtraction: { - serializedName: "defaultAnswerUsedForExtraction", - constraints: { - MaxLength: 300, - MinLength: 1 - }, - type: { - name: "String" - } - }, - language: { - serializedName: "language", - constraints: { - MaxLength: 100, - MinLength: 1 - }, + context: { + serializedName: "context", type: { - name: "String" + 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" } } } @@ -843,163 +298,108 @@ 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", + previousQnaId: { + serializedName: "previousQnaId", type: { name: "String" } }, - resourceLocation: { - serializedName: "resourceLocation", + previousUserQuery: { + serializedName: "previousUserQuery", type: { name: "String" } - }, - userId: { - serializedName: "userId", - type: { - name: "String" - } - }, - operationId: { - serializedName: "operationId", - 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", + ...QueryContextDTO.type.modelProperties + } + } +}; + +export const QueryDTO: msRest.CompositeMapper = { + serializedName: "QueryDTO", + type: { + name: "Composite", + className: "QueryDTO", + modelProperties: { + qnaId: { + serializedName: "qnaId", type: { name: "String" } }, - hostName: { - serializedName: "hostName", + question: { + serializedName: "question", type: { name: "String" } }, - lastAccessedTimestamp: { - serializedName: "lastAccessedTimestamp", + top: { + serializedName: "top", type: { - name: "String" + name: "Number" } }, - lastChangedTimestamp: { - serializedName: "lastChangedTimestamp", + userId: { + serializedName: "userId", type: { name: "String" } }, - lastPublishedTimestamp: { - serializedName: "lastPublishedTimestamp", + isTest: { + serializedName: "isTest", type: { - name: "String" + name: "Boolean" } }, - name: { - serializedName: "name", + scoreThreshold: { + serializedName: "scoreThreshold", type: { - name: "String" + name: "Number" } }, - userId: { - serializedName: "userId", + context: { + serializedName: "context", type: { - name: "String" + name: "Composite", + className: "QueryDTOContext" } }, - urls: { - serializedName: "urls", + rankerType: { + serializedName: "rankerType", type: { - name: "Sequence", - element: { - type: { - name: "String" - } - } + name: "String" } }, - sources: { - serializedName: "sources", - type: { - name: "Sequence", - element: { - type: { - name: "String" - } - } - } - } - } - } -}; - -export const KnowledgebasesDTO: msRest.CompositeMapper = { - serializedName: "KnowledgebasesDTO", - type: { - name: "Composite", - className: "KnowledgebasesDTO", - modelProperties: { - knowledgebases: { - serializedName: "knowledgebases", + strictFilters: { + serializedName: "strictFilters", type: { name: "Sequence", element: { type: { name: "Composite", - className: "KnowledgebaseDTO" + className: "MetadataDTO" } } } - } - } - } -}; - -export const ActiveLearningSettingsDTO: msRest.CompositeMapper = { - serializedName: "ActiveLearningSettingsDTO", - type: { - name: "Composite", - className: "ActiveLearningSettingsDTO", - modelProperties: { - enable: { - serializedName: "enable", + }, + strictFiltersCompoundOperationType: { + serializedName: "strictFiltersCompoundOperationType", type: { name: "String" } @@ -1008,71 +408,95 @@ export const ActiveLearningSettingsDTO: msRest.CompositeMapper = { } }; -export const EndpointSettingsDTOActiveLearning: msRest.CompositeMapper = { - serializedName: "EndpointSettingsDTO_activeLearning", +export const QnASearchResultContext: msRest.CompositeMapper = { + serializedName: "QnASearchResult_context", type: { name: "Composite", - className: "EndpointSettingsDTOActiveLearning", + className: "QnASearchResultContext", modelProperties: { - ...ActiveLearningSettingsDTO.type.modelProperties + ...ContextDTO.type.modelProperties } } }; -export const EndpointSettingsDTO: msRest.CompositeMapper = { - serializedName: "EndpointSettingsDTO", +export const QnASearchResult: msRest.CompositeMapper = { + serializedName: "QnASearchResult", type: { name: "Composite", - className: "EndpointSettingsDTO", + className: "QnASearchResult", modelProperties: { - activeLearning: { - serializedName: "activeLearning", + questions: { + serializedName: "questions", type: { - name: "Composite", - className: "EndpointSettingsDTOActiveLearning" + name: "Sequence", + element: { + type: { + name: "String" + } + } } - } - } - } -}; - -export const AlterationsDTO: msRest.CompositeMapper = { - serializedName: "AlterationsDTO", - type: { - name: "Composite", - className: "AlterationsDTO", - modelProperties: { - alterations: { - required: true, - serializedName: "alterations", + }, + 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: "String" + 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" } } } @@ -1081,54 +505,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", - type: { - name: "String" - } - }, - installedVersion: { - serializedName: "installedVersion", + userId: { + serializedName: "userId", type: { name: "String" } }, - lastStableVersion: { - serializedName: "lastStableVersion", + userQuestion: { + serializedName: "userQuestion", + constraints: { + MaxLength: 1000 + }, type: { name: "String" } }, - language: { - serializedName: "language", - 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" } @@ -1137,16 +536,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 a9c7055c493d..0f494ad8e07c 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/parameters.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/models/parameters.ts @@ -10,28 +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, - serializedName: "environment", - type: { - name: "String" - } - } -}; export const kbId: msRest.OperationURLParameter = { parameterPath: "kbId", mapper: { @@ -42,23 +20,15 @@ export const kbId: msRest.OperationURLParameter = { } } }; -export const keyType: msRest.OperationURLParameter = { - parameterPath: "keyType", +export const runtimeEndpoint: msRest.OperationURLParameter = { + parameterPath: "runtimeEndpoint", mapper: { required: true, - serializedName: "keyType", - type: { - name: "String" - } - } -}; -export const operationId: msRest.OperationURLParameter = { - parameterPath: "operationId", - mapper: { - required: true, - 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 index 9b21f50dbcdf..bd092c5dd289 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/endpointSettings.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/endpointSettings.ts @@ -54,28 +54,28 @@ export class EndpointSettings { * @summary Updates endpoint settings for an endpoint. * @param endpointSettingsPayload Post body of the request. * @param [options] The optional parameters - * @returns Promise + * @returns Promise */ - updateSettings(endpointSettingsPayload: Models.EndpointSettingsDTO, options?: msRest.RequestOptionsBase): 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; + 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 { + 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; + callback); } } @@ -112,14 +112,7 @@ const updateSettingsOperationSpec: msRest.OperationSpec = { } }, responses: { - 200: { - bodyMapper: { - serializedName: "parsedResponse", - type: { - name: "String" - } - } - }, + 204: {}, default: { bodyMapper: Mappers.ErrorResponse } diff --git a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/index.ts b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/index.ts index e67a8e209eb3..943e2f1af5f1 100644 --- a/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/index.ts +++ b/sdk/cognitiveservices/cognitiveservices-qnamaker/src/operations/index.ts @@ -8,8 +8,4 @@ * regenerated. */ -export * from "./endpointSettings"; -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/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..7c5d89b45284 --- /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 = "3.1.1"; + +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; + } +}