Skip to content

Commit

Permalink
feat: Added client library support for ModerateText in the Natural La…
Browse files Browse the repository at this point in the history
…nguage API (V1)

PiperOrigin-RevId: 534992604
  • Loading branch information
Google APIs authored and Copybara-Service committed May 24, 2023
1 parent 2ddddd1 commit 2400fac
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion google/cloud/language/v1/BUILD.bazel
Expand Up @@ -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",
Expand Down
30 changes: 28 additions & 2 deletions google/cloud/language/v1/language_service.proto
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

0 comments on commit 2400fac

Please sign in to comment.