Skip to content

Commit 8e70b7f

Browse files
feat(discov2): generation release changes
1 parent 403145e commit 8e70b7f

File tree

3 files changed

+390
-9
lines changed

3 files changed

+390
-9
lines changed

discovery/v2.ts

Lines changed: 204 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2019, 2020.
2+
* (C) Copyright IBM Corp. 2019, 2021.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,9 +15,9 @@
1515
*/
1616

1717
/**
18-
* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-8d569e8f-20201103-112432
18+
* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-902c9336-20210507-162723
1919
*/
20-
20+
2121

2222
import * as extend from 'extend';
2323
import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http';
@@ -47,7 +47,7 @@ class DiscoveryV2 extends BaseService {
4747
* @param {Object} options - Options for the service.
4848
* @param {string} options.version - Release date of the version of the API you want to use. Specify dates in
4949
* 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.
5151
* @param {OutgoingHttpHeaders} [options.headers] - Default headers that shall be included with every request to the service.
5252
* @param {string} [options.serviceName] - The name of the service to configure
5353
* @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 {
508508
};
509509

510510
/**
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.
512577
*
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.
515580
*
516581
* @param {Object} params - The parameters to send to the service.
517582
* @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 {
11951260
return this.createRequest(parameters);
11961261
};
11971262

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+
11981311
/*************************
11991312
* analyze
12001313
************************/
@@ -1335,7 +1448,7 @@ class DiscoveryV2 extends BaseService {
13351448
* @param {Object} params - The parameters to send to the service.
13361449
* @param {string} params.projectId - The ID of the project. This information can be found from the deploy page of the
13371450
* Discovery administrative tooling.
1338-
* @param {CreateEnrichment} params.enrichment -
1451+
* @param {CreateEnrichment} params.enrichment - Information about a specific enrichment.
13391452
* @param {NodeJS.ReadableStream|Buffer} [params.file] - The enrichment file to upload.
13401453
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
13411454
* @returns {Promise<DiscoveryV2.Response<DiscoveryV2.Enrichment>>}
@@ -2019,6 +2132,38 @@ namespace DiscoveryV2 {
20192132
headers?: OutgoingHttpHeaders;
20202133
}
20212134

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+
20222167
/** Parameters for the `queryNotices` operation. */
20232168
export interface QueryNoticesParams {
20242169
/** The ID of the project. This information can be found from the deploy page of the Discovery administrative
@@ -2243,6 +2388,17 @@ namespace DiscoveryV2 {
22432388
headers?: OutgoingHttpHeaders;
22442389
}
22452390

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+
22462402
/** Parameters for the `analyzeDocument` operation. */
22472403
export interface AnalyzeDocumentParams {
22482404
/** The ID of the project. This information can be found from the deploy page of the Discovery administrative
@@ -2300,6 +2456,7 @@ namespace DiscoveryV2 {
23002456
* tooling.
23012457
*/
23022458
projectId: string;
2459+
/** Information about a specific enrichment. */
23032460
enrichment: CreateEnrichment;
23042461
/** The enrichment file to upload. */
23052462
file?: NodeJS.ReadableStream|Buffer;
@@ -2819,6 +2976,25 @@ namespace DiscoveryV2 {
28192976
count?: number;
28202977
/** The approximate number of characters that any one passage will have. */
28212978
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;
28222998
}
28232999

28243000
/** Configuration for suggested refinements. */
@@ -2881,6 +3057,10 @@ namespace DiscoveryV2 {
28813057
end_offset?: number;
28823058
/** The label of the field from which the passage has been extracted. */
28833059
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[];
28843064
}
28853065

28863066
/** Result document for the specified query. */
@@ -2922,6 +3102,10 @@ namespace DiscoveryV2 {
29223102
end_offset?: number;
29233103
/** The label of the field from which the passage has been extracted. */
29243104
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[];
29253109
}
29263110

29273111
/** A suggested additional query term or terms user to filter results. */
@@ -2986,6 +3170,18 @@ namespace DiscoveryV2 {
29863170
hits?: JsonObject[];
29873171
}
29883172

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+
29893185
/** An object contain retrieval type information. */
29903186
export interface RetrievalDetails {
29913187
/** Identifies the document retrieval strategy used for this query. `relevancy_training` indicates that the

test/integration/discovery.v2.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,18 @@ describe('discovery v2 integration @slow', () => {
232232
expect(result).toBeDefined();
233233
});
234234

235+
test('queryCollectionNotices', async () => {
236+
const params = {
237+
projectId,
238+
collectionId,
239+
};
240+
241+
const res = await discovery.queryCollectionNotices(params);
242+
expect(res).toBeDefined();
243+
const { result } = res || {};
244+
expect(result).toBeDefined();
245+
});
246+
235247
test('listFields', async () => {
236248
const params = {
237249
projectId,

0 commit comments

Comments
 (0)