// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.ai.generativelanguage.v1beta;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/struct.proto";

option go_package = "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb;generativelanguagepb";
option java_multiple_files = true;
option java_outer_classname = "PredictionServiceProto";
option java_package = "com.google.ai.generativelanguage.v1beta";

// A service for online predictions and explanations.
service PredictionService {
  option (google.api.default_host) = "generativelanguage.googleapis.com";

  // Performs a prediction request.
  rpc Predict(PredictRequest) returns (PredictResponse) {
    option (google.api.http) = {
      post: "/v1beta/{model=models/*}:predict"
      body: "*"
    };
    option (google.api.method_signature) = "model,instances";
  }

  // Same as Predict but returns an LRO.
  rpc PredictLongRunning(PredictLongRunningRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1beta/{model=models/*}:predictLongRunning"
      body: "*"
    };
    option (google.api.method_signature) = "model,instances";
    option (google.longrunning.operation_info) = {
      response_type: "PredictLongRunningResponse"
      metadata_type: "PredictLongRunningMetadata"
    };
  }
}

// Request message for
// [PredictionService.Predict][google.ai.generativelanguage.v1beta.PredictionService.Predict].
message PredictRequest {
  // Required. The name of the model for prediction.
  // Format: `name=models/{model}`.
  string model = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "generativelanguage.googleapis.com/Model"
    }
  ];

  // Required. The instances that are the input to the prediction call.
  repeated google.protobuf.Value instances = 2
      [(google.api.field_behavior) = REQUIRED];

  // Optional. The parameters that govern the prediction call.
  google.protobuf.Value parameters = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Request message for [PredictionService.PredictLongRunning].
message PredictLongRunningRequest {
  // Required. The name of the model for prediction.
  // Format: `name=models/{model}`.
  string model = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "generativelanguage.googleapis.com/Model"
    }
  ];

  // Required. The instances that are the input to the prediction call.
  repeated google.protobuf.Value instances = 2
      [(google.api.field_behavior) = REQUIRED];

  // Optional. The parameters that govern the prediction call.
  google.protobuf.Value parameters = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for [PredictionService.Predict].
message PredictResponse {
  // The outputs of the prediction call.
  repeated google.protobuf.Value predictions = 1;
}

// Response message for [PredictionService.PredictLongRunning]
message PredictLongRunningResponse {
  // The response of the long running operation.
  oneof response {
    // The response of the video generation prediction.
    GenerateVideoResponse generate_video_response = 1;
  }
}

// Metadata for PredictLongRunning long running operations.
message PredictLongRunningMetadata {}

// A proto encapsulate various type of media.
message Media {
  // Type of media.
  oneof type {
    // Video as the only one for now.  This is mimicking Vertex proto.
    Video video = 1;
  }
}

// Representation of a video.
message Video {
  // Where the video content is.
  oneof content {
    // Raw bytes.
    bytes video = 1;

    // Path to another storage.
    string uri = 2;
  }
}

// Veo response.
message GenerateVideoResponse {
  // The generated samples.
  repeated Media generated_samples = 1;

  // Returns if any videos were filtered due to RAI policies.
  int32 rai_media_filtered_count = 2;

  // Returns rai failure reasons if any.
  repeated string rai_media_filtered_reasons = 3;
}
