v1alpha1.d.ts
17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
/**
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { OAuth2Client, JWT, Compute, UserRefreshClient } from 'google-auth-library';
import { GoogleConfigurable, MethodOptions, GlobalOptions, BodyResponseCallback, APIRequestContext } from 'googleapis-common';
import { GaxiosPromise } from 'gaxios';
export declare namespace commentanalyzer_v1alpha1 {
export interface Options extends GlobalOptions {
version: 'v1alpha1';
}
interface StandardParameters {
/**
* V1 error format.
*/
'$.xgafv'?: string;
/**
* OAuth access token.
*/
access_token?: string;
/**
* Data format for response.
*/
alt?: string;
/**
* JSONP
*/
callback?: string;
/**
* Selector specifying which fields to include in a partial response.
*/
fields?: string;
/**
* API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
*/
key?: string;
/**
* OAuth 2.0 token for the current user.
*/
oauth_token?: string;
/**
* Returns response with indentations and line breaks.
*/
prettyPrint?: boolean;
/**
* Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
*/
quotaUser?: string;
/**
* Legacy upload protocol for media (e.g. "media", "multipart").
*/
uploadType?: string;
/**
* Upload protocol for media (e.g. "raw", "multipart").
*/
upload_protocol?: string;
}
/**
* Perspective Comment Analyzer API
*
* The Perspective Comment Analyzer API provides information about the potential impact of a comment on a conversation (e.g. it can provide a score for the "toxicity" of a comment). Users can leverage the "SuggestCommentScore" method to submit corrections to improve Perspective over time. Users can set the "doNotStore" flag to ensure that all submitted comments are automatically deleted after scores are returned.
*
* @example
* const {google} = require('googleapis');
* const commentanalyzer = google.commentanalyzer('v1alpha1');
*
* @namespace commentanalyzer
* @type {Function}
* @version v1alpha1
* @variation v1alpha1
* @param {object=} options Options for Commentanalyzer
*/
export class Commentanalyzer {
context: APIRequestContext;
comments: Resource$Comments;
constructor(options: GlobalOptions, google?: GoogleConfigurable);
}
/**
* The comment analysis request message. LINT.IfChange
*/
export interface Schema$AnalyzeCommentRequest {
/**
* Opaque token that is echoed from the request to the response.
*/
clientToken?: string | null;
/**
* The comment to analyze.
*/
comment?: Schema$TextEntry;
/**
* Optional identifier associating this AnalyzeCommentRequest with a particular client's community. Different communities may have different norms and rules. Specifying this value enables us to explore building community-specific models for clients.
*/
communityId?: string | null;
/**
* The context of the comment.
*/
context?: Schema$Context;
/**
* Do not store the comment or context sent in this request. By default, the service may store comments/context for debugging purposes.
*/
doNotStore?: boolean | null;
/**
* The language(s) of the comment and context (if none are specified, the language is automatically detected). If multiple languages are specified, the text is checked in all of them that are supported. Both ISO and BCP-47 language codes are accepted. Current Language Restrictions: * Only English text ("en") is supported. If none of the languages specified by the caller are supported, an `UNIMPLEMENTED` error is returned.
*/
languages?: string[] | null;
/**
* Specification of requested attributes. The AttributeParameters serve as configuration for each associated attribute. The map keys are attribute names. The available attributes may be different on each RFE installation, and can be seen by calling ListAttributes (see above). For the prod installation, known as Perspective API, at blade:commentanalyzer-esf and commentanalyzer.googleapis.com, see go/checker-models (internal) and https://github.com/conversationai/perspectiveapi/blob/master/api_reference.md#models.
*/
requestedAttributes?: {
[key: string]: Schema$AttributeParameters;
} | null;
/**
* Session ID. Used to join related RPCs into a single session. For example, an interactive tool that calls both the AnalyzeComment and SuggestCommentScore RPCs should set all invocations of both RPCs to the same Session ID, typically a random 64-bit integer.
*/
sessionId?: string | null;
/**
* An advisory parameter that will return span annotations if the model is capable of providing scores with sub-comment resolution. This will likely increase the size of the returned message.
*/
spanAnnotations?: boolean | null;
}
/**
* The comment analysis response message.
*/
export interface Schema$AnalyzeCommentResponse {
/**
* Scores for the requested attributes. The map keys are attribute names (same as the requested_attribute field in AnalyzeCommentRequest, for example "ATTACK_ON_AUTHOR", "INFLAMMATORY", etc).
*/
attributeScores?: {
[key: string]: Schema$AttributeScores;
} | null;
/**
* Same token from the original AnalyzeCommentRequest.
*/
clientToken?: string | null;
/**
* Contains the languages detected from the text content, sorted in order of likelihood.
*/
detectedLanguages?: string[] | null;
/**
* The language(s) used by CommentAnalyzer service to choose which Model to use when analyzing the comment. Might better be called "effective_languages". The logic used to make the choice is as follows: if Request.languages.empty() effective_languages = detected_languages else effective_languages = Request.languages
*/
languages?: string[] | null;
}
/**
* A type of context specific to a comment left on a single-threaded comment message board, where comments are either a top level comment or the child of a top level comment.
*/
export interface Schema$ArticleAndParentComment {
/**
* The source content about which the comment was made (article text, article summary, video transcript, etc).
*/
article?: Schema$TextEntry;
/**
* Refers to text that is a direct parent of the source comment, such as in a one-deep threaded message board. This field will only be present for comments that are replies to other comments and will not be populated for direct comments on the article_text.
*/
parentComment?: Schema$TextEntry;
}
/**
* Configurable parameters for attribute scoring.
*/
export interface Schema$AttributeParameters {
/**
* Don't return scores for this attribute that are below this threshold. If unset, a default threshold will be applied. A FloatValue wrapper is used to distinguish between 0 vs. default/unset.
*/
scoreThreshold?: number | null;
/**
* What type of scores to return. If unset, defaults to probability scores.
*/
scoreType?: string | null;
}
/**
* This holds score values for a single attribute. It contains both per-span scores as well as an overall summary score..
*/
export interface Schema$AttributeScores {
/**
* Per-span scores.
*/
spanScores?: Schema$SpanScore[];
/**
* Overall score for comment as a whole.
*/
summaryScore?: Schema$Score;
}
/**
* Context is typically something that a Comment is referencing or replying to (such as an article, or previous comment). Note: Populate only ONE OF the following fields. The oneof syntax cannot be used because that would require nesting entries inside another message and breaking backwards compatibility. The server will return an error if more than one of the following fields is present.
*/
export interface Schema$Context {
/**
* Information about the source for which the original comment was made, and any parent comment info.
*/
articleAndParentComment?: Schema$ArticleAndParentComment;
/**
* A list of messages. For example, a linear comments section or forum thread.
*/
entries?: Schema$TextEntry[];
}
/**
* Analysis scores are described by a value and a ScoreType.
*/
export interface Schema$Score {
/**
* The type of the above value.
*/
type?: string | null;
/**
* Score value. Semantics described by type below.
*/
value?: number | null;
}
/**
* This is a single score for a given span of text.
*/
export interface Schema$SpanScore {
/**
* "begin" and "end" describe the span of the original text that the attribute score applies to. The values are the UTF-16 codepoint range. "end" is exclusive. For example, with the text "Hi there", the begin/end pair (0,2) describes the text "Hi". If "begin" and "end" are unset, the score applies to the full text.
*/
begin?: number | null;
end?: number | null;
/**
* The score value.
*/
score?: Schema$Score;
}
/**
* The comment score suggestion request message.
*/
export interface Schema$SuggestCommentScoreRequest {
/**
* Attribute scores for the comment. The map keys are attribute names, same as the requested_attribute field in AnalyzeCommentRequest (for example "ATTACK_ON_AUTHOR", "INFLAMMATORY", etc.). This field has the same type as the `attribute_scores` field in AnalyzeCommentResponse. To specify an overall attribute score for the entire comment as a whole, use the `summary_score` field of the mapped AttributeScores object. To specify scores on specific subparts of the comment, use the `span_scores` field. All SpanScore objects must have begin and end fields set. All Score objects must be explicitly set (for binary classification, use the score values 0 and 1). If Score objects don't include a ScoreType, `PROBABILITY` is assumed. `attribute_scores` must not be empty. The mapped AttributeScores objects also must not be empty. An `INVALID_ARGUMENT` error is returned for all malformed requests.
*/
attributeScores?: {
[key: string]: Schema$AttributeScores;
} | null;
/**
* Opaque token that is echoed from the request to the response.
*/
clientToken?: string | null;
/**
* The comment being scored.
*/
comment?: Schema$TextEntry;
/**
* Optional identifier associating this comment score suggestion with a particular sub-community. Different communities may have different norms and rules. Specifying this value enables training community-specific models.
*/
communityId?: string | null;
/**
* The context of the comment.
*/
context?: Schema$Context;
/**
* The language(s) of the comment and context (if none are specified, the language is automatically detected). If multiple languages are specified, the text is checked in all of them that are supported. Both ISO and BCP-47 language codes are accepted. Current Language Restrictions: * Only English text ("en") is supported. If none of the languages specified by the caller are supported, an `UNIMPLEMENTED` error is returned.
*/
languages?: string[] | null;
/**
* Session ID. Used to join related RPCs into a single session. For example, an interactive tool that calls both the AnalyzeComment and SuggestCommentScore RPCs should set all invocations of both RPCs to the same Session ID, typically a random 64-bit integer.
*/
sessionId?: string | null;
}
/**
* The comment score suggestion response message.
*/
export interface Schema$SuggestCommentScoreResponse {
/**
* Same token from the original SuggestCommentScoreRequest.
*/
clientToken?: string | null;
/**
* The list of languages detected from the comment text.
*/
detectedLanguages?: string[] | null;
/**
* The list of languages provided in the request.
*/
requestedLanguages?: string[] | null;
}
/**
* Represents a body of text.
*/
export interface Schema$TextEntry {
/**
* UTF-8 encoded text.
*/
text?: string | null;
/**
* Type of the text field.
*/
type?: string | null;
}
export class Resource$Comments {
context: APIRequestContext;
constructor(context: APIRequestContext);
/**
* commentanalyzer.comments.analyze
* @desc Analyzes the provided text and returns scores for requested attributes.
* @alias commentanalyzer.comments.analyze
* @memberOf! ()
*
* @param {object} params Parameters for request
* @param {().AnalyzeCommentRequest} params.resource Request body data
* @param {object} [options] Optionally override request options, such as `url`, `method`, and `encoding`.
* @param {callback} callback The callback that handles the response.
* @return {object} Request object
*/
analyze(params?: Params$Resource$Comments$Analyze, options?: MethodOptions): GaxiosPromise<Schema$AnalyzeCommentResponse>;
analyze(params: Params$Resource$Comments$Analyze, options: MethodOptions | BodyResponseCallback<Schema$AnalyzeCommentResponse>, callback: BodyResponseCallback<Schema$AnalyzeCommentResponse>): void;
analyze(params: Params$Resource$Comments$Analyze, callback: BodyResponseCallback<Schema$AnalyzeCommentResponse>): void;
analyze(callback: BodyResponseCallback<Schema$AnalyzeCommentResponse>): void;
/**
* commentanalyzer.comments.suggestscore
* @desc Suggest comment scores as training data.
* @alias commentanalyzer.comments.suggestscore
* @memberOf! ()
*
* @param {object} params Parameters for request
* @param {().SuggestCommentScoreRequest} params.resource Request body data
* @param {object} [options] Optionally override request options, such as `url`, `method`, and `encoding`.
* @param {callback} callback The callback that handles the response.
* @return {object} Request object
*/
suggestscore(params?: Params$Resource$Comments$Suggestscore, options?: MethodOptions): GaxiosPromise<Schema$SuggestCommentScoreResponse>;
suggestscore(params: Params$Resource$Comments$Suggestscore, options: MethodOptions | BodyResponseCallback<Schema$SuggestCommentScoreResponse>, callback: BodyResponseCallback<Schema$SuggestCommentScoreResponse>): void;
suggestscore(params: Params$Resource$Comments$Suggestscore, callback: BodyResponseCallback<Schema$SuggestCommentScoreResponse>): void;
suggestscore(callback: BodyResponseCallback<Schema$SuggestCommentScoreResponse>): void;
}
export interface Params$Resource$Comments$Analyze extends StandardParameters {
/**
* Auth client or API Key for the request
*/
auth?: string | OAuth2Client | JWT | Compute | UserRefreshClient;
/**
* Request body metadata
*/
requestBody?: Schema$AnalyzeCommentRequest;
}
export interface Params$Resource$Comments$Suggestscore extends StandardParameters {
/**
* Auth client or API Key for the request
*/
auth?: string | OAuth2Client | JWT | Compute | UserRefreshClient;
/**
* Request body metadata
*/
requestBody?: Schema$SuggestCommentScoreRequest;
}
export {};
}