|
1 | 1 | /**
|
2 |
| - * (C) Copyright IBM Corp. 2019, 2020. |
| 2 | + * (C) Copyright IBM Corp. 2019, 2021. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
15 | 15 | */
|
16 | 16 |
|
17 | 17 | /**
|
18 |
| - * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-8d569e8f-20201103-112432 |
| 18 | + * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-902c9336-20210507-162723 |
19 | 19 | */
|
20 |
| - |
| 20 | + |
21 | 21 |
|
22 | 22 | import * as extend from 'extend';
|
23 | 23 | import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http';
|
@@ -47,7 +47,7 @@ class DiscoveryV2 extends BaseService {
|
47 | 47 | * @param {Object} options - Options for the service.
|
48 | 48 | * @param {string} options.version - Release date of the version of the API you want to use. Specify dates in
|
49 | 49 | * YYYY-MM-DD format. The current version is `2019-11-22`.
|
50 |
| - * @param {string} [options.serviceUrl] - The base url to use when contacting the service (e.g. 'https://api.us-south.discovery.watson.cloud.ibm.com'). The base url may differ between IBM Cloud regions. |
| 50 | + * @param {string} [options.serviceUrl] - The base url to use when contacting the service. The base url may differ between IBM Cloud regions. |
51 | 51 | * @param {OutgoingHttpHeaders} [options.headers] - Default headers that shall be included with every request to the service.
|
52 | 52 | * @param {string} [options.serviceName] - The name of the service to configure
|
53 | 53 | * @param {Authenticator} [options.authenticator] - The Authenticator object used to authenticate requests to the service. Defaults to environment if not set
|
@@ -508,10 +508,75 @@ class DiscoveryV2 extends BaseService {
|
508 | 508 | };
|
509 | 509 |
|
510 | 510 | /**
|
511 |
| - * Query system notices. |
| 511 | + * Query collection notices. |
| 512 | + * |
| 513 | + * Finds collection-level notices (errors and warnings) that are generated when documents are ingested. |
| 514 | + * |
| 515 | + * @param {Object} params - The parameters to send to the service. |
| 516 | + * @param {string} params.projectId - The ID of the project. This information can be found from the deploy page of the |
| 517 | + * Discovery administrative tooling. |
| 518 | + * @param {string} params.collectionId - The ID of the collection. |
| 519 | + * @param {string} [params.filter] - A cacheable query that excludes documents that don't mention the query content. |
| 520 | + * Filter searches are better for metadata-type searches and for assessing the concepts in the data set. |
| 521 | + * @param {string} [params.query] - A query search returns all documents in your data set with full enrichments and |
| 522 | + * full text, but with the most relevant documents listed first. |
| 523 | + * @param {string} [params.naturalLanguageQuery] - A natural language query that returns relevant documents by |
| 524 | + * utilizing training data and natural language understanding. |
| 525 | + * @param {number} [params.count] - Number of results to return. The maximum for the **count** and **offset** values |
| 526 | + * together in any one query is **10000**. |
| 527 | + * @param {number} [params.offset] - The number of query results to skip at the beginning. For example, if the total |
| 528 | + * number of results that are returned is 10 and the offset is 8, it returns the last two results. The maximum for the |
| 529 | + * **count** and **offset** values together in any one query is **10000**. |
| 530 | + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers |
| 531 | + * @returns {Promise<DiscoveryV2.Response<DiscoveryV2.QueryNoticesResponse>>} |
| 532 | + */ |
| 533 | + public queryCollectionNotices(params: DiscoveryV2.QueryCollectionNoticesParams): Promise<DiscoveryV2.Response<DiscoveryV2.QueryNoticesResponse>> { |
| 534 | + const _params = Object.assign({}, params); |
| 535 | + const requiredParams = ['projectId', 'collectionId']; |
| 536 | + |
| 537 | + const missingParams = getMissingParams(_params, requiredParams); |
| 538 | + if (missingParams) { |
| 539 | + return Promise.reject(missingParams); |
| 540 | + } |
| 541 | + |
| 542 | + const query = { |
| 543 | + 'version': this.version, |
| 544 | + 'filter': _params.filter, |
| 545 | + 'query': _params.query, |
| 546 | + 'natural_language_query': _params.naturalLanguageQuery, |
| 547 | + 'count': _params.count, |
| 548 | + 'offset': _params.offset |
| 549 | + }; |
| 550 | + |
| 551 | + const path = { |
| 552 | + 'project_id': _params.projectId, |
| 553 | + 'collection_id': _params.collectionId |
| 554 | + }; |
| 555 | + |
| 556 | + const sdkHeaders = getSdkHeaders(DiscoveryV2.DEFAULT_SERVICE_NAME, 'v2', 'queryCollectionNotices'); |
| 557 | + |
| 558 | + const parameters = { |
| 559 | + options: { |
| 560 | + url: '/v2/projects/{project_id}/collections/{collection_id}/notices', |
| 561 | + method: 'GET', |
| 562 | + qs: query, |
| 563 | + path, |
| 564 | + }, |
| 565 | + defaultOptions: extend(true, {}, this.baseOptions, { |
| 566 | + headers: extend(true, sdkHeaders, { |
| 567 | + 'Accept': 'application/json', |
| 568 | + }, _params.headers), |
| 569 | + }), |
| 570 | + }; |
| 571 | + |
| 572 | + return this.createRequest(parameters); |
| 573 | + }; |
| 574 | + |
| 575 | + /** |
| 576 | + * Query project notices. |
512 | 577 | *
|
513 |
| - * Queries for notices (errors or warnings) that might have been generated by the system. Notices are generated when |
514 |
| - * ingesting documents and performing relevance training. |
| 578 | + * Finds project-level notices (errors and warnings). Currently, project-level notices are generated by relevancy |
| 579 | + * training. |
515 | 580 | *
|
516 | 581 | * @param {Object} params - The parameters to send to the service.
|
517 | 582 | * @param {string} params.projectId - The ID of the project. This information can be found from the deploy page of the
|
@@ -1195,6 +1260,54 @@ class DiscoveryV2 extends BaseService {
|
1195 | 1260 | return this.createRequest(parameters);
|
1196 | 1261 | };
|
1197 | 1262 |
|
| 1263 | + /** |
| 1264 | + * Delete a training data query. |
| 1265 | + * |
| 1266 | + * Removes details from a training data query, including the query string and all examples. |
| 1267 | + * |
| 1268 | + * @param {Object} params - The parameters to send to the service. |
| 1269 | + * @param {string} params.projectId - The ID of the project. This information can be found from the deploy page of the |
| 1270 | + * Discovery administrative tooling. |
| 1271 | + * @param {string} params.queryId - The ID of the query used for training. |
| 1272 | + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers |
| 1273 | + * @returns {Promise<DiscoveryV2.Response<DiscoveryV2.Empty>>} |
| 1274 | + */ |
| 1275 | + public deleteTrainingQuery(params: DiscoveryV2.DeleteTrainingQueryParams): Promise<DiscoveryV2.Response<DiscoveryV2.Empty>> { |
| 1276 | + const _params = Object.assign({}, params); |
| 1277 | + const requiredParams = ['projectId', 'queryId']; |
| 1278 | + |
| 1279 | + const missingParams = getMissingParams(_params, requiredParams); |
| 1280 | + if (missingParams) { |
| 1281 | + return Promise.reject(missingParams); |
| 1282 | + } |
| 1283 | + |
| 1284 | + const query = { |
| 1285 | + 'version': this.version |
| 1286 | + }; |
| 1287 | + |
| 1288 | + const path = { |
| 1289 | + 'project_id': _params.projectId, |
| 1290 | + 'query_id': _params.queryId |
| 1291 | + }; |
| 1292 | + |
| 1293 | + const sdkHeaders = getSdkHeaders(DiscoveryV2.DEFAULT_SERVICE_NAME, 'v2', 'deleteTrainingQuery'); |
| 1294 | + |
| 1295 | + const parameters = { |
| 1296 | + options: { |
| 1297 | + url: '/v2/projects/{project_id}/training_data/queries/{query_id}', |
| 1298 | + method: 'DELETE', |
| 1299 | + qs: query, |
| 1300 | + path, |
| 1301 | + }, |
| 1302 | + defaultOptions: extend(true, {}, this.baseOptions, { |
| 1303 | + headers: extend(true, sdkHeaders, { |
| 1304 | + }, _params.headers), |
| 1305 | + }), |
| 1306 | + }; |
| 1307 | + |
| 1308 | + return this.createRequest(parameters); |
| 1309 | + }; |
| 1310 | + |
1198 | 1311 | /*************************
|
1199 | 1312 | * analyze
|
1200 | 1313 | ************************/
|
@@ -1335,7 +1448,7 @@ class DiscoveryV2 extends BaseService {
|
1335 | 1448 | * @param {Object} params - The parameters to send to the service.
|
1336 | 1449 | * @param {string} params.projectId - The ID of the project. This information can be found from the deploy page of the
|
1337 | 1450 | * Discovery administrative tooling.
|
1338 |
| - * @param {CreateEnrichment} params.enrichment - |
| 1451 | + * @param {CreateEnrichment} params.enrichment - Information about a specific enrichment. |
1339 | 1452 | * @param {NodeJS.ReadableStream|Buffer} [params.file] - The enrichment file to upload.
|
1340 | 1453 | * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
|
1341 | 1454 | * @returns {Promise<DiscoveryV2.Response<DiscoveryV2.Enrichment>>}
|
@@ -2019,6 +2132,38 @@ namespace DiscoveryV2 {
|
2019 | 2132 | headers?: OutgoingHttpHeaders;
|
2020 | 2133 | }
|
2021 | 2134 |
|
| 2135 | + /** Parameters for the `queryCollectionNotices` operation. */ |
| 2136 | + export interface QueryCollectionNoticesParams { |
| 2137 | + /** The ID of the project. This information can be found from the deploy page of the Discovery administrative |
| 2138 | + * tooling. |
| 2139 | + */ |
| 2140 | + projectId: string; |
| 2141 | + /** The ID of the collection. */ |
| 2142 | + collectionId: string; |
| 2143 | + /** A cacheable query that excludes documents that don't mention the query content. Filter searches are better |
| 2144 | + * for metadata-type searches and for assessing the concepts in the data set. |
| 2145 | + */ |
| 2146 | + filter?: string; |
| 2147 | + /** A query search returns all documents in your data set with full enrichments and full text, but with the most |
| 2148 | + * relevant documents listed first. |
| 2149 | + */ |
| 2150 | + query?: string; |
| 2151 | + /** A natural language query that returns relevant documents by utilizing training data and natural language |
| 2152 | + * understanding. |
| 2153 | + */ |
| 2154 | + naturalLanguageQuery?: string; |
| 2155 | + /** Number of results to return. The maximum for the **count** and **offset** values together in any one query |
| 2156 | + * is **10000**. |
| 2157 | + */ |
| 2158 | + count?: number; |
| 2159 | + /** The number of query results to skip at the beginning. For example, if the total number of results that are |
| 2160 | + * returned is 10 and the offset is 8, it returns the last two results. The maximum for the **count** and |
| 2161 | + * **offset** values together in any one query is **10000**. |
| 2162 | + */ |
| 2163 | + offset?: number; |
| 2164 | + headers?: OutgoingHttpHeaders; |
| 2165 | + } |
| 2166 | + |
2022 | 2167 | /** Parameters for the `queryNotices` operation. */
|
2023 | 2168 | export interface QueryNoticesParams {
|
2024 | 2169 | /** The ID of the project. This information can be found from the deploy page of the Discovery administrative
|
@@ -2243,6 +2388,17 @@ namespace DiscoveryV2 {
|
2243 | 2388 | headers?: OutgoingHttpHeaders;
|
2244 | 2389 | }
|
2245 | 2390 |
|
| 2391 | + /** Parameters for the `deleteTrainingQuery` operation. */ |
| 2392 | + export interface DeleteTrainingQueryParams { |
| 2393 | + /** The ID of the project. This information can be found from the deploy page of the Discovery administrative |
| 2394 | + * tooling. |
| 2395 | + */ |
| 2396 | + projectId: string; |
| 2397 | + /** The ID of the query used for training. */ |
| 2398 | + queryId: string; |
| 2399 | + headers?: OutgoingHttpHeaders; |
| 2400 | + } |
| 2401 | + |
2246 | 2402 | /** Parameters for the `analyzeDocument` operation. */
|
2247 | 2403 | export interface AnalyzeDocumentParams {
|
2248 | 2404 | /** The ID of the project. This information can be found from the deploy page of the Discovery administrative
|
@@ -2300,6 +2456,7 @@ namespace DiscoveryV2 {
|
2300 | 2456 | * tooling.
|
2301 | 2457 | */
|
2302 | 2458 | projectId: string;
|
| 2459 | + /** Information about a specific enrichment. */ |
2303 | 2460 | enrichment: CreateEnrichment;
|
2304 | 2461 | /** The enrichment file to upload. */
|
2305 | 2462 | file?: NodeJS.ReadableStream|Buffer;
|
@@ -2819,6 +2976,25 @@ namespace DiscoveryV2 {
|
2819 | 2976 | count?: number;
|
2820 | 2977 | /** The approximate number of characters that any one passage will have. */
|
2821 | 2978 | characters?: number;
|
| 2979 | + /** When true, `answer` objects are returned as part of each passage in the query results. The primary |
| 2980 | + * difference between an `answer` and a `passage` is that the length of a passage is defined by the query, where |
| 2981 | + * the length of an `answer` is calculated by Discovery based on how much text is needed to answer the |
| 2982 | + * question./n/nThis parameter is ignored if passages are not enabled for the query, or no |
| 2983 | + * **natural_language_query** is specified./n/nIf the **find_answers** parameter is set to `true` and |
| 2984 | + * **per_document** parameter is also set to `true`, then the document search results and the passage search |
| 2985 | + * results within each document are reordered using the answer confidences. The goal of this reordering is to do as |
| 2986 | + * much as possible to make sure that the first answer of the first passage of the first document is the best |
| 2987 | + * answer. Similarly, if the **find_answers** parameter is set to `true` and **per_document** parameter is set to |
| 2988 | + * `false`, then the passage search results are reordered in decreasing order of the highest confidence answer for |
| 2989 | + * each document and passage./n/nThe **find_answers** parameter is **beta** functionality available only on managed |
| 2990 | + * instances and should not be used in a production environment. This parameter is not available on installed |
| 2991 | + * instances of Discovery. |
| 2992 | + */ |
| 2993 | + find_answers?: boolean; |
| 2994 | + /** The number of `answer` objects to return per passage if the **find_answers** parmeter is specified as |
| 2995 | + * `true`. |
| 2996 | + */ |
| 2997 | + max_answers_per_passage?: number; |
2822 | 2998 | }
|
2823 | 2999 |
|
2824 | 3000 | /** Configuration for suggested refinements. */
|
@@ -2881,6 +3057,10 @@ namespace DiscoveryV2 {
|
2881 | 3057 | end_offset?: number;
|
2882 | 3058 | /** The label of the field from which the passage has been extracted. */
|
2883 | 3059 | field?: string;
|
| 3060 | + /** An estimate of the probability that the passage is relevant. */ |
| 3061 | + confidence?: number; |
| 3062 | + /** An array of extracted answers to the specified query. */ |
| 3063 | + answers?: ResultPassageAnswer[]; |
2884 | 3064 | }
|
2885 | 3065 |
|
2886 | 3066 | /** Result document for the specified query. */
|
@@ -2922,6 +3102,10 @@ namespace DiscoveryV2 {
|
2922 | 3102 | end_offset?: number;
|
2923 | 3103 | /** The label of the field from which the passage has been extracted. */
|
2924 | 3104 | field?: string;
|
| 3105 | + /** Estimate of the probability that the passage is relevant. */ |
| 3106 | + confidence?: number; |
| 3107 | + /** An arry of extracted answers to the specified query. */ |
| 3108 | + answers?: ResultPassageAnswer[]; |
2925 | 3109 | }
|
2926 | 3110 |
|
2927 | 3111 | /** A suggested additional query term or terms user to filter results. */
|
@@ -2986,6 +3170,18 @@ namespace DiscoveryV2 {
|
2986 | 3170 | hits?: JsonObject[];
|
2987 | 3171 | }
|
2988 | 3172 |
|
| 3173 | + /** Object containing a potential answer to the specified query. */ |
| 3174 | + export interface ResultPassageAnswer { |
| 3175 | + /** Answer text for the specified query as identified by Discovery. */ |
| 3176 | + answer_text?: string; |
| 3177 | + /** The position of the first character of the extracted answer in the originating field. */ |
| 3178 | + start_offset?: number; |
| 3179 | + /** The position of the last character of the extracted answer in the originating field. */ |
| 3180 | + end_offset?: number; |
| 3181 | + /** An estimate of the probability that the answer is relevant. */ |
| 3182 | + confidence?: number; |
| 3183 | + } |
| 3184 | + |
2989 | 3185 | /** An object contain retrieval type information. */
|
2990 | 3186 | export interface RetrievalDetails {
|
2991 | 3187 | /** Identifies the document retrieval strategy used for this query. `relevancy_training` indicates that the
|
|
0 commit comments