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", name = "language_php_gapic",
srcs = [":language_proto_with_info"], srcs = [":language_proto_with_info"],
grpc_service_config = "language_grpc_service_config.json", grpc_service_config = "language_grpc_service_config.json",
migration_mode = "MIGRATING",
rest_numeric_enums = True, rest_numeric_enums = True,
service_yaml = "language_v1.yaml", service_yaml = "language_v1.yaml",
transport = "grpc+rest", transport = "grpc+rest",
migration_mode = "MIGRATING",
deps = [ deps = [
":language_php_grpc", ":language_php_grpc",
":language_php_proto", ":language_php_proto",

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

Loading…
Cancel
Save