@@ -23,10 +23,12 @@ import "google/api/resource.proto";
2323import "google/cloud/documentai/v1/document.proto" ;
2424import "google/cloud/documentai/v1/document_io.proto" ;
2525import "google/cloud/documentai/v1/document_schema.proto" ;
26+ import "google/cloud/documentai/v1/evaluation.proto" ;
2627import "google/cloud/documentai/v1/operation_metadata.proto" ;
2728import "google/cloud/documentai/v1/processor.proto" ;
2829import "google/cloud/documentai/v1/processor_type.proto" ;
2930import "google/longrunning/operations.proto" ;
31+ import "google/protobuf/empty.proto" ;
3032import "google/protobuf/field_mask.proto" ;
3133import "google/protobuf/timestamp.proto" ;
3234import "google/rpc/status.proto" ;
@@ -131,6 +133,22 @@ service DocumentProcessorService {
131133 option (google.api.method_signature ) = "name" ;
132134 }
133135
136+ // Trains a new processor version.
137+ // Operation metadata is returned as
138+ // cloud_documentai_core.TrainProcessorVersionMetadata.
139+ rpc TrainProcessorVersion (TrainProcessorVersionRequest )
140+ returns (google.longrunning.Operation ) {
141+ option (google.api.http ) = {
142+ post : "/v1/{parent=projects/*/locations/*/processors/*}/processorVersions:train"
143+ body : "*"
144+ };
145+ option (google.api.method_signature ) = "parent,processor_version" ;
146+ option (google.longrunning.operation_info ) = {
147+ response_type : "TrainProcessorVersionResponse"
148+ metadata_type : "TrainProcessorVersionMetadata"
149+ };
150+ }
151+
134152 // Gets a processor version detail.
135153 rpc GetProcessorVersion (GetProcessorVersionRequest )
136154 returns (ProcessorVersion ) {
@@ -272,6 +290,38 @@ service DocumentProcessorService {
272290 metadata_type : "ReviewDocumentOperationMetadata"
273291 };
274292 }
293+
294+ // Evaluates a ProcessorVersion against annotated documents, producing an
295+ // Evaluation.
296+ rpc EvaluateProcessorVersion (EvaluateProcessorVersionRequest )
297+ returns (google.longrunning.Operation ) {
298+ option (google.api.http ) = {
299+ post : "/v1/{processor_version=projects/*/locations/*/processors/*/processorVersions/*}:evaluateProcessorVersion"
300+ body : "*"
301+ };
302+ option (google.api.method_signature ) = "processor_version" ;
303+ option (google.longrunning.operation_info ) = {
304+ response_type : "EvaluateProcessorVersionResponse"
305+ metadata_type : "EvaluateProcessorVersionMetadata"
306+ };
307+ }
308+
309+ // Retrieves a specific evaluation.
310+ rpc GetEvaluation (GetEvaluationRequest ) returns (Evaluation ) {
311+ option (google.api.http ) = {
312+ get : "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*/evaluations/*}"
313+ };
314+ option (google.api.method_signature ) = "name" ;
315+ }
316+
317+ // Retrieves a set of evaluations for a given processor version.
318+ rpc ListEvaluations (ListEvaluationsRequest )
319+ returns (ListEvaluationsResponse ) {
320+ option (google.api.http ) = {
321+ get : "/v1/{parent=projects/*/locations/*/processors/*/processorVersions/*}/evaluations"
322+ };
323+ option (google.api.method_signature ) = "parent" ;
324+ }
275325}
276326
277327// Request message for the process document method.
@@ -758,6 +808,81 @@ message SetDefaultProcessorVersionMetadata {
758808 CommonOperationMetadata common_metadata = 1 ;
759809}
760810
811+ // Request message for the create processor version method.
812+ message TrainProcessorVersionRequest {
813+ // The input data used to train a new `ProcessorVersion`.
814+ message InputData {
815+ // The documents used for training the new version.
816+ BatchDocumentsInputConfig training_documents = 3 ;
817+
818+ // The documents used for testing the trained version.
819+ BatchDocumentsInputConfig test_documents = 4 ;
820+ }
821+
822+ // Required. The parent (project, location and processor) to create the new
823+ // version for. Format:
824+ // `projects/{project}/locations/{location}/processors/{processor}`.
825+ string parent = 1 [
826+ (google.api.field_behavior ) = REQUIRED ,
827+ (google.api.resource_reference ) = {
828+ type : "documentai.googleapis.com/Processor"
829+ }
830+ ];
831+
832+ // Required. The processor version to be created.
833+ ProcessorVersion processor_version = 2
834+ [(google.api.field_behavior ) = REQUIRED ];
835+
836+ // Optional. The schema the processor version will be trained with.
837+ DocumentSchema document_schema = 10 [(google.api.field_behavior ) = OPTIONAL ];
838+
839+ // Optional. The input data used to train the `ProcessorVersion`.
840+ InputData input_data = 4 [(google.api.field_behavior ) = OPTIONAL ];
841+
842+ // Optional. The processor version to use as a base for training. This
843+ // processor version must be a child of `parent`. Format:
844+ // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`.
845+ string base_processor_version = 8 [(google.api.field_behavior ) = OPTIONAL ];
846+ }
847+
848+ // The response for the TrainProcessorVersion method.
849+ message TrainProcessorVersionResponse {
850+ // The resource name of the processor version produced by training.
851+ string processor_version = 1 ;
852+ }
853+
854+ // The metadata that represents a processor version being created.
855+ message TrainProcessorVersionMetadata {
856+ // The dataset validation information.
857+ // This includes any and all errors with documents and the dataset.
858+ message DatasetValidation {
859+ // The total number of document errors.
860+ int32 document_error_count = 3 ;
861+
862+ // The total number of dataset errors.
863+ int32 dataset_error_count = 4 ;
864+
865+ // Error information pertaining to specific documents. A maximum of 10
866+ // document errors will be returned.
867+ // Any document with errors will not be used throughout training.
868+ repeated google.rpc.Status document_errors = 1 ;
869+
870+ // Error information for the dataset as a whole. A maximum of 10 dataset
871+ // errors will be returned.
872+ // A single dataset error is terminal for training.
873+ repeated google.rpc.Status dataset_errors = 2 ;
874+ }
875+
876+ // The basic metadata of the long running operation.
877+ CommonOperationMetadata common_metadata = 1 ;
878+
879+ // The training dataset validation information.
880+ DatasetValidation training_dataset_validation = 2 ;
881+
882+ // The test dataset validation information.
883+ DatasetValidation test_dataset_validation = 3 ;
884+ }
885+
761886// Request message for review document method.
762887message ReviewDocumentRequest {
763888 // The priority level of the human review task.
@@ -828,3 +953,80 @@ message ReviewDocumentOperationMetadata {
828953 // The Crowd Compute question ID.
829954 string question_id = 6 ;
830955}
956+
957+ // Evaluates the given ProcessorVersion against the supplied documents.
958+ message EvaluateProcessorVersionRequest {
959+ // Required. The resource name of the
960+ // [ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion] to
961+ // evaluate.
962+ // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
963+ string processor_version = 1 [
964+ (google.api.field_behavior ) = REQUIRED ,
965+ (google.api.resource_reference ) = {
966+ type : "documentai.googleapis.com/ProcessorVersion"
967+ }
968+ ];
969+
970+ // Optional. The documents used in the evaluation. If unspecified, use the
971+ // processor's dataset as evaluation input.
972+ BatchDocumentsInputConfig evaluation_documents = 3
973+ [(google.api.field_behavior ) = OPTIONAL ];
974+ }
975+
976+ // Metadata of the EvaluateProcessorVersion method.
977+ message EvaluateProcessorVersionMetadata {
978+ // The basic metadata of the long running operation.
979+ CommonOperationMetadata common_metadata = 1 ;
980+ }
981+
982+ // Metadata of the EvaluateProcessorVersion method.
983+ message EvaluateProcessorVersionResponse {
984+ // The resource name of the created evaluation.
985+ string evaluation = 2 ;
986+ }
987+
988+ // Retrieves a specific Evaluation.
989+ message GetEvaluationRequest {
990+ // Required. The resource name of the
991+ // [Evaluation][google.cloud.documentai.v1.Evaluation] to get.
992+ // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}/evaluations/{evaluation}`
993+ string name = 1 [
994+ (google.api.field_behavior ) = REQUIRED ,
995+ (google.api.resource_reference ) = {
996+ type : "documentai.googleapis.com/Evaluation"
997+ }
998+ ];
999+ }
1000+
1001+ // Retrieves a list of evaluations for a given ProcessorVersion.
1002+ message ListEvaluationsRequest {
1003+ // Required. The resource name of the
1004+ // [ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion] to list
1005+ // evaluations for.
1006+ // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
1007+ string parent = 1 [
1008+ (google.api.field_behavior ) = REQUIRED ,
1009+ (google.api.resource_reference ) = {
1010+ type : "documentai.googleapis.com/ProcessorVersion"
1011+ }
1012+ ];
1013+
1014+ // The standard list page size.
1015+ // If unspecified, at most 5 evaluations will be returned.
1016+ // The maximum value is 100; values above 100 will be coerced to 100.
1017+ int32 page_size = 2 ;
1018+
1019+ // A page token, received from a previous `ListEvaluations` call.
1020+ // Provide this to retrieve the subsequent page.
1021+ string page_token = 3 ;
1022+ }
1023+
1024+ // The response from ListEvaluations.
1025+ message ListEvaluationsResponse {
1026+ // The evaluations requested.
1027+ repeated Evaluation evaluations = 1 ;
1028+
1029+ // A token, which can be sent as `page_token` to retrieve the next page.
1030+ // If this field is omitted, there are no subsequent pages.
1031+ string next_page_token = 2 ;
1032+ }
0 commit comments