Skip to content

Commit 2400fac

Browse files
Google APIscopybara-github
authored andcommitted
feat: Added client library support for ModerateText in the Natural Language API (V1)
PiperOrigin-RevId: 534992604
1 parent 2ddddd1 commit 2400fac

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

google/cloud/language/v1/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,10 @@ php_gapic_library(
220220
name = "language_php_gapic",
221221
srcs = [":language_proto_with_info"],
222222
grpc_service_config = "language_grpc_service_config.json",
223+
migration_mode = "MIGRATING",
223224
rest_numeric_enums = True,
224225
service_yaml = "language_v1.yaml",
225226
transport = "grpc+rest",
226-
migration_mode = "MIGRATING",
227227
deps = [
228228
":language_php_grpc",
229229
":language_php_proto",

google/cloud/language/v1/language_service.proto

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ service LanguageService {
9292
option (google.api.method_signature) = "document";
9393
}
9494

95+
// Moderates a document for harmful and sensitive categories.
96+
rpc ModerateText(ModerateTextRequest) returns (ModerateTextResponse) {
97+
option (google.api.http) = {
98+
post: "/v1/documents:moderateText"
99+
body: "*"
100+
};
101+
option (google.api.method_signature) = "document";
102+
}
103+
95104
// A convenience method that provides all the features that analyzeSentiment,
96105
// analyzeEntities, and analyzeSyntax provide in one call.
97106
rpc AnnotateText(AnnotateTextRequest) returns (AnnotateTextResponse) {
@@ -966,8 +975,7 @@ message TextSpan {
966975

967976
// Represents a category returned from the text classifier.
968977
message ClassificationCategory {
969-
// The name of the category representing the document, from the [predefined
970-
// taxonomy](https://cloud.google.com/natural-language/docs/categories).
978+
// The name of the category representing the document.
971979
string name = 1;
972980

973981
// The classifier's confidence of the category. Number represents how certain
@@ -1118,6 +1126,18 @@ message ClassifyTextResponse {
11181126
repeated ClassificationCategory categories = 1;
11191127
}
11201128

1129+
// The document moderation request message.
1130+
message ModerateTextRequest {
1131+
// Required. Input document.
1132+
Document document = 1 [(google.api.field_behavior) = REQUIRED];
1133+
}
1134+
1135+
// The document moderation response message.
1136+
message ModerateTextResponse {
1137+
// Harmful and sensitive categories representing the input document.
1138+
repeated ClassificationCategory moderation_categories = 1;
1139+
}
1140+
11211141
// The request message for the text annotation API, which can perform multiple
11221142
// analysis types (sentiment, entities, and syntax) in one call.
11231143
message AnnotateTextRequest {
@@ -1139,6 +1159,9 @@ message AnnotateTextRequest {
11391159
// Classify the full document into categories.
11401160
bool classify_text = 6;
11411161

1162+
// Moderate the document for harmful and sensitive categories.
1163+
bool moderate_text = 11;
1164+
11421165
// The model options to use for classification. Defaults to v1 options
11431166
// if not specified. Only used if `classify_text` is set to true.
11441167
ClassificationModelOptions classification_model_options = 10;
@@ -1182,4 +1205,7 @@ message AnnotateTextResponse {
11821205

11831206
// Categories identified in the input document.
11841207
repeated ClassificationCategory categories = 6;
1208+
1209+
// Harmful and sensitive categories identified in the input document.
1210+
repeated ClassificationCategory moderation_categories = 7;
11851211
}

0 commit comments

Comments
 (0)