Skip to content

Commit 2d4fbff

Browse files
Google APIscopybara-github
authored andcommitted
feat: Added the ability to use the Model Armor service for content sanitization
PiperOrigin-RevId: 788957149
1 parent 435851d commit 2d4fbff

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

google/cloud/aiplatform/v1/content.proto

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ syntax = "proto3";
1717
package google.cloud.aiplatform.v1;
1818

1919
import "google/api/field_behavior.proto";
20+
import "google/api/resource.proto";
2021
import "google/cloud/aiplatform/v1/openapi.proto";
2122
import "google/cloud/aiplatform/v1/tool.proto";
2223
import "google/cloud/aiplatform/v1/vertex_rag_data.proto";
@@ -31,6 +32,10 @@ option java_outer_classname = "ContentProto";
3132
option java_package = "com.google.cloud.aiplatform.v1";
3233
option php_namespace = "Google\\Cloud\\AIPlatform\\V1";
3334
option ruby_package = "Google::Cloud::AIPlatform::V1";
35+
option (google.api.resource_definition) = {
36+
type: "modelarmor.googleapis.com/Template"
37+
pattern: "projects/{project}/locations/{location}/templates/{template}"
38+
};
3439

3540
// Harm categories that will block the content.
3641
enum HarmCategory {
@@ -503,6 +508,9 @@ message Candidate {
503508

504509
// The function call generated by the model is invalid.
505510
MALFORMED_FUNCTION_CALL = 9;
511+
512+
// The model response was blocked by Model Armor.
513+
MODEL_ARMOR = 10;
506514
}
507515

508516
// Output only. Index of the candidate.
@@ -725,6 +733,27 @@ message RetrievalMetadata {
725733
[(google.api.field_behavior) = OPTIONAL];
726734
}
727735

736+
// Configuration for Model Armor integrations of prompt and responses.
737+
message ModelArmorConfig {
738+
// Optional. The name of the Model Armor template to use for prompt
739+
// sanitization.
740+
string prompt_template_name = 1 [
741+
(google.api.field_behavior) = OPTIONAL,
742+
(google.api.resource_reference) = {
743+
type: "modelarmor.googleapis.com/Template"
744+
}
745+
];
746+
747+
// Optional. The name of the Model Armor template to use for response
748+
// sanitization.
749+
string response_template_name = 2 [
750+
(google.api.field_behavior) = OPTIONAL,
751+
(google.api.resource_reference) = {
752+
type: "modelarmor.googleapis.com/Template"
753+
}
754+
];
755+
}
756+
728757
// Represents token counting info for a single modality.
729758
message ModalityTokenCount {
730759
// The modality associated with this token count.

google/cloud/aiplatform/v1/prediction_service.proto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,11 @@ message GenerateContentRequest {
738738
repeated SafetySetting safety_settings = 3
739739
[(google.api.field_behavior) = OPTIONAL];
740740

741+
// Optional. Settings for prompt and response sanitization using the Model
742+
// Armor service. If supplied, safety_settings must not be supplied.
743+
ModelArmorConfig model_armor_config = 11
744+
[(google.api.field_behavior) = OPTIONAL];
745+
741746
// Optional. Generation config.
742747
GenerationConfig generation_config = 4
743748
[(google.api.field_behavior) = OPTIONAL];
@@ -764,6 +769,9 @@ message GenerateContentResponse {
764769

765770
// Candidates blocked due to prohibited content.
766771
PROHIBITED_CONTENT = 4;
772+
773+
// The user prompt was blocked by Model Armor.
774+
MODEL_ARMOR = 5;
767775
}
768776

769777
// Output only. Blocked reason.

0 commit comments

Comments
 (0)