Skip to content

Commit

Permalink
feat(discov2): generation release changes
Browse files Browse the repository at this point in the history
  • Loading branch information
apaparazzi0329 committed May 26, 2021
1 parent 403145e commit 8e70b7f
Show file tree
Hide file tree
Showing 3 changed files with 390 additions and 9 deletions.
212 changes: 204 additions & 8 deletions discovery/v2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corp. 2019, 2020.
* (C) Copyright IBM Corp. 2019, 2021.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,9 +15,9 @@
*/

/**
* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-8d569e8f-20201103-112432
* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-902c9336-20210507-162723
*/


import * as extend from 'extend';
import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http';
Expand Down Expand Up @@ -47,7 +47,7 @@ class DiscoveryV2 extends BaseService {
* @param {Object} options - Options for the service.
* @param {string} options.version - Release date of the version of the API you want to use. Specify dates in
* YYYY-MM-DD format. The current version is `2019-11-22`.
* @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.
* @param {string} [options.serviceUrl] - The base url to use when contacting the service. The base url may differ between IBM Cloud regions.
* @param {OutgoingHttpHeaders} [options.headers] - Default headers that shall be included with every request to the service.
* @param {string} [options.serviceName] - The name of the service to configure
* @param {Authenticator} [options.authenticator] - The Authenticator object used to authenticate requests to the service. Defaults to environment if not set
Expand Down Expand Up @@ -508,10 +508,75 @@ class DiscoveryV2 extends BaseService {
};

/**
* Query system notices.
* Query collection notices.
*
* Finds collection-level notices (errors and warnings) that are generated when documents are ingested.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.projectId - The ID of the project. This information can be found from the deploy page of the
* Discovery administrative tooling.
* @param {string} params.collectionId - The ID of the collection.
* @param {string} [params.filter] - A cacheable query that excludes documents that don't mention the query content.
* Filter searches are better for metadata-type searches and for assessing the concepts in the data set.
* @param {string} [params.query] - A query search returns all documents in your data set with full enrichments and
* full text, but with the most relevant documents listed first.
* @param {string} [params.naturalLanguageQuery] - A natural language query that returns relevant documents by
* utilizing training data and natural language understanding.
* @param {number} [params.count] - Number of results to return. The maximum for the **count** and **offset** values
* together in any one query is **10000**.
* @param {number} [params.offset] - The number of query results to skip at the beginning. For example, if the total
* number of results that are returned is 10 and the offset is 8, it returns the last two results. The maximum for the
* **count** and **offset** values together in any one query is **10000**.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<DiscoveryV2.Response<DiscoveryV2.QueryNoticesResponse>>}
*/
public queryCollectionNotices(params: DiscoveryV2.QueryCollectionNoticesParams): Promise<DiscoveryV2.Response<DiscoveryV2.QueryNoticesResponse>> {
const _params = Object.assign({}, params);
const requiredParams = ['projectId', 'collectionId'];

const missingParams = getMissingParams(_params, requiredParams);
if (missingParams) {
return Promise.reject(missingParams);
}

const query = {
'version': this.version,
'filter': _params.filter,
'query': _params.query,
'natural_language_query': _params.naturalLanguageQuery,
'count': _params.count,
'offset': _params.offset
};

const path = {
'project_id': _params.projectId,
'collection_id': _params.collectionId
};

const sdkHeaders = getSdkHeaders(DiscoveryV2.DEFAULT_SERVICE_NAME, 'v2', 'queryCollectionNotices');

const parameters = {
options: {
url: '/v2/projects/{project_id}/collections/{collection_id}/notices',
method: 'GET',
qs: query,
path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
'Accept': 'application/json',
}, _params.headers),
}),
};

return this.createRequest(parameters);
};

/**
* Query project notices.
*
* Queries for notices (errors or warnings) that might have been generated by the system. Notices are generated when
* ingesting documents and performing relevance training.
* Finds project-level notices (errors and warnings). Currently, project-level notices are generated by relevancy
* training.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.projectId - The ID of the project. This information can be found from the deploy page of the
Expand Down Expand Up @@ -1195,6 +1260,54 @@ class DiscoveryV2 extends BaseService {
return this.createRequest(parameters);
};

/**
* Delete a training data query.
*
* Removes details from a training data query, including the query string and all examples.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.projectId - The ID of the project. This information can be found from the deploy page of the
* Discovery administrative tooling.
* @param {string} params.queryId - The ID of the query used for training.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<DiscoveryV2.Response<DiscoveryV2.Empty>>}
*/
public deleteTrainingQuery(params: DiscoveryV2.DeleteTrainingQueryParams): Promise<DiscoveryV2.Response<DiscoveryV2.Empty>> {
const _params = Object.assign({}, params);
const requiredParams = ['projectId', 'queryId'];

const missingParams = getMissingParams(_params, requiredParams);
if (missingParams) {
return Promise.reject(missingParams);
}

const query = {
'version': this.version
};

const path = {
'project_id': _params.projectId,
'query_id': _params.queryId
};

const sdkHeaders = getSdkHeaders(DiscoveryV2.DEFAULT_SERVICE_NAME, 'v2', 'deleteTrainingQuery');

const parameters = {
options: {
url: '/v2/projects/{project_id}/training_data/queries/{query_id}',
method: 'DELETE',
qs: query,
path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(true, sdkHeaders, {
}, _params.headers),
}),
};

return this.createRequest(parameters);
};

/*************************
* analyze
************************/
Expand Down Expand Up @@ -1335,7 +1448,7 @@ class DiscoveryV2 extends BaseService {
* @param {Object} params - The parameters to send to the service.
* @param {string} params.projectId - The ID of the project. This information can be found from the deploy page of the
* Discovery administrative tooling.
* @param {CreateEnrichment} params.enrichment -
* @param {CreateEnrichment} params.enrichment - Information about a specific enrichment.
* @param {NodeJS.ReadableStream|Buffer} [params.file] - The enrichment file to upload.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<DiscoveryV2.Response<DiscoveryV2.Enrichment>>}
Expand Down Expand Up @@ -2019,6 +2132,38 @@ namespace DiscoveryV2 {
headers?: OutgoingHttpHeaders;
}

/** Parameters for the `queryCollectionNotices` operation. */
export interface QueryCollectionNoticesParams {
/** The ID of the project. This information can be found from the deploy page of the Discovery administrative
* tooling.
*/
projectId: string;
/** The ID of the collection. */
collectionId: string;
/** A cacheable query that excludes documents that don't mention the query content. Filter searches are better
* for metadata-type searches and for assessing the concepts in the data set.
*/
filter?: string;
/** A query search returns all documents in your data set with full enrichments and full text, but with the most
* relevant documents listed first.
*/
query?: string;
/** A natural language query that returns relevant documents by utilizing training data and natural language
* understanding.
*/
naturalLanguageQuery?: string;
/** Number of results to return. The maximum for the **count** and **offset** values together in any one query
* is **10000**.
*/
count?: number;
/** The number of query results to skip at the beginning. For example, if the total number of results that are
* returned is 10 and the offset is 8, it returns the last two results. The maximum for the **count** and
* **offset** values together in any one query is **10000**.
*/
offset?: number;
headers?: OutgoingHttpHeaders;
}

/** Parameters for the `queryNotices` operation. */
export interface QueryNoticesParams {
/** The ID of the project. This information can be found from the deploy page of the Discovery administrative
Expand Down Expand Up @@ -2243,6 +2388,17 @@ namespace DiscoveryV2 {
headers?: OutgoingHttpHeaders;
}

/** Parameters for the `deleteTrainingQuery` operation. */
export interface DeleteTrainingQueryParams {
/** The ID of the project. This information can be found from the deploy page of the Discovery administrative
* tooling.
*/
projectId: string;
/** The ID of the query used for training. */
queryId: string;
headers?: OutgoingHttpHeaders;
}

/** Parameters for the `analyzeDocument` operation. */
export interface AnalyzeDocumentParams {
/** The ID of the project. This information can be found from the deploy page of the Discovery administrative
Expand Down Expand Up @@ -2300,6 +2456,7 @@ namespace DiscoveryV2 {
* tooling.
*/
projectId: string;
/** Information about a specific enrichment. */
enrichment: CreateEnrichment;
/** The enrichment file to upload. */
file?: NodeJS.ReadableStream|Buffer;
Expand Down Expand Up @@ -2819,6 +2976,25 @@ namespace DiscoveryV2 {
count?: number;
/** The approximate number of characters that any one passage will have. */
characters?: number;
/** When true, `answer` objects are returned as part of each passage in the query results. The primary
* difference between an `answer` and a `passage` is that the length of a passage is defined by the query, where
* the length of an `answer` is calculated by Discovery based on how much text is needed to answer the
* question./n/nThis parameter is ignored if passages are not enabled for the query, or no
* **natural_language_query** is specified./n/nIf the **find_answers** parameter is set to `true` and
* **per_document** parameter is also set to `true`, then the document search results and the passage search
* results within each document are reordered using the answer confidences. The goal of this reordering is to do as
* much as possible to make sure that the first answer of the first passage of the first document is the best
* answer. Similarly, if the **find_answers** parameter is set to `true` and **per_document** parameter is set to
* `false`, then the passage search results are reordered in decreasing order of the highest confidence answer for
* each document and passage./n/nThe **find_answers** parameter is **beta** functionality available only on managed
* instances and should not be used in a production environment. This parameter is not available on installed
* instances of Discovery.
*/
find_answers?: boolean;
/** The number of `answer` objects to return per passage if the **find_answers** parmeter is specified as
* `true`.
*/
max_answers_per_passage?: number;
}

/** Configuration for suggested refinements. */
Expand Down Expand Up @@ -2881,6 +3057,10 @@ namespace DiscoveryV2 {
end_offset?: number;
/** The label of the field from which the passage has been extracted. */
field?: string;
/** An estimate of the probability that the passage is relevant. */
confidence?: number;
/** An array of extracted answers to the specified query. */
answers?: ResultPassageAnswer[];
}

/** Result document for the specified query. */
Expand Down Expand Up @@ -2922,6 +3102,10 @@ namespace DiscoveryV2 {
end_offset?: number;
/** The label of the field from which the passage has been extracted. */
field?: string;
/** Estimate of the probability that the passage is relevant. */
confidence?: number;
/** An arry of extracted answers to the specified query. */
answers?: ResultPassageAnswer[];
}

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

/** Object containing a potential answer to the specified query. */
export interface ResultPassageAnswer {
/** Answer text for the specified query as identified by Discovery. */
answer_text?: string;
/** The position of the first character of the extracted answer in the originating field. */
start_offset?: number;
/** The position of the last character of the extracted answer in the originating field. */
end_offset?: number;
/** An estimate of the probability that the answer is relevant. */
confidence?: number;
}

/** An object contain retrieval type information. */
export interface RetrievalDetails {
/** Identifies the document retrieval strategy used for this query. `relevancy_training` indicates that the
Expand Down
12 changes: 12 additions & 0 deletions test/integration/discovery.v2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,18 @@ describe('discovery v2 integration @slow', () => {
expect(result).toBeDefined();
});

test('queryCollectionNotices', async () => {
const params = {
projectId,
collectionId,
};

const res = await discovery.queryCollectionNotices(params);
expect(res).toBeDefined();
const { result } = res || {};
expect(result).toBeDefined();
});

test('listFields', async () => {
const params = {
projectId,
Expand Down
Loading

0 comments on commit 8e70b7f

Please sign in to comment.