feat: Added client library support for ModerateText in the Natural Language API (V1)

PiperOrigin-RevId: 534992604
pull/807/head^2
Google APIs 2 years ago committed by Copybara-Service
parent 2ddddd1af7
commit 2400facb5e
  1. 2
      google/cloud/language/v1/BUILD.bazel
  2. 30
      google/cloud/language/v1/language_service.proto

@ -220,10 +220,10 @@ php_gapic_library(
name = "language_php_gapic",
srcs = [":language_proto_with_info"],
grpc_service_config = "language_grpc_service_config.json",
migration_mode = "MIGRATING",
rest_numeric_enums = True,
service_yaml = "language_v1.yaml",
transport = "grpc+rest",
migration_mode = "MIGRATING",
deps = [
":language_php_grpc",
":language_php_proto",

@ -92,6 +92,15 @@ service LanguageService {
option (google.api.method_signature) = "document";
}
// Moderates a document for harmful and sensitive categories.
rpc ModerateText(ModerateTextRequest) returns (ModerateTextResponse) {
option (google.api.http) = {
post: "/v1/documents:moderateText"
body: "*"
};
option (google.api.method_signature) = "document";
}
// A convenience method that provides all the features that analyzeSentiment,
// analyzeEntities, and analyzeSyntax provide in one call.
rpc AnnotateText(AnnotateTextRequest) returns (AnnotateTextResponse) {
@ -966,8 +975,7 @@ message TextSpan {
// Represents a category returned from the text classifier.
message ClassificationCategory {
// The name of the category representing the document, from the [predefined
// taxonomy](https://cloud.google.com/natural-language/docs/categories).
// The name of the category representing the document.
string name = 1;
// The classifier's confidence of the category. Number represents how certain
@ -1118,6 +1126,18 @@ message ClassifyTextResponse {
repeated ClassificationCategory categories = 1;
}
// The document moderation request message.
message ModerateTextRequest {
// Required. Input document.
Document document = 1 [(google.api.field_behavior) = REQUIRED];
}
// The document moderation response message.
message ModerateTextResponse {
// Harmful and sensitive categories representing the input document.
repeated ClassificationCategory moderation_categories = 1;
}
// The request message for the text annotation API, which can perform multiple
// analysis types (sentiment, entities, and syntax) in one call.
message AnnotateTextRequest {
@ -1139,6 +1159,9 @@ message AnnotateTextRequest {
// Classify the full document into categories.
bool classify_text = 6;
// Moderate the document for harmful and sensitive categories.
bool moderate_text = 11;
// The model options to use for classification. Defaults to v1 options
// if not specified. Only used if `classify_text` is set to true.
ClassificationModelOptions classification_model_options = 10;
@ -1182,4 +1205,7 @@ message AnnotateTextResponse {
// Categories identified in the input document.
repeated ClassificationCategory categories = 6;
// Harmful and sensitive categories identified in the input document.
repeated ClassificationCategory moderation_categories = 7;
}

Loading…
Cancel
Save