// Copyright 2026 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.cloud.discoveryengine.v1beta;

import "google/api/field_behavior.proto";
import "google/cloud/discoveryengine/v1beta/session.proto";

option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta";
option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb";
option java_multiple_files = true;
option java_outer_classname = "FeedbackProto";
option java_package = "com.google.cloud.discoveryengine.v1beta";
option objc_class_prefix = "DISCOVERYENGINE";
option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta";
option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta";

// Information about the user feedback. This information will be used for
// logging and metrics purpose.
message Feedback {
  // The conversation information such as the question index and session name.
  message ConversationInfo {
    // The index of the user input within the conversation messages.
    int32 question_index = 1;

    // Name of the newly generated or continued session.
    string session = 2;

    // Required. The user's search query.
    Query query = 3 [(google.api.field_behavior) = REQUIRED];

    // Optional. The token which could be used to fetch the assistant log.
    string assist_token = 4 [(google.api.field_behavior) = OPTIONAL];

    // Optional. The token which could be used to fetch the answer log.
    string answer_query_token = 5 [(google.api.field_behavior) = OPTIONAL];
  }

  // The type of the feedback user gives.
  enum FeedbackType {
    // Unspecified feedback type.
    FEEDBACK_TYPE_UNSPECIFIED = 0;

    // The user gives a positive feedback.
    LIKE = 1;

    // The user gives a negative feedback.
    DISLIKE = 2;
  }

  // The reason why user gives a negative feedback.
  enum Reason {
    // Unspecified reason.
    REASON_UNSPECIFIED = 0;

    // The response is inaccurate.
    INACCURATE_RESPONSE = 1;

    // The response is not relevant.
    NOT_RELEVANT = 2;

    // The response is incomprehensive.
    INCOMPREHENSIVE = 3;

    // The response is offensive or unsafe.
    OFFENSIVE_OR_UNSAFE = 4;

    // The response is not well-formatted.
    FORMAT_AND_STYLES = 6;

    // The response is not well-associated with the query.
    BAD_CITATION = 7;

    // The expected canvas was not generated for the response.
    CANVAS_NOT_GENERATED = 8;

    // The generated canvas is of bad quality (e.g. inaccurate, incomplete,
    // poorly formatted).
    CANVAS_QUALITY_BAD = 9;

    // Exporting the generated canvas failed (e.g. download or external
    // export action did not complete successfully).
    CANVAS_EXPORT_FAILED = 10;
  }

  // Source of the feedback as per integration.
  enum FeedbackSource {
    // Unspecified feedback source.
    FEEDBACK_SOURCE_UNSPECIFIED = 0;

    // Feedback source is Google Console.
    GOOGLE_CONSOLE = 1;

    // Feedback source is Google Widget.
    GOOGLE_WIDGET = 2;

    // Feedback source is Google Webapp.
    GOOGLE_WEBAPP = 3;

    // Feedback source is Google AgentSpace Mobile app.
    GOOGLE_AGENTSPACE_MOBILE = 4;
  }

  // Required. Indicate whether the user gives a positive or negative feedback.
  // If the user gives a negative feedback, there might be more feedback
  // details.
  FeedbackType feedback_type = 1 [(google.api.field_behavior) = REQUIRED];

  // Optional. The reason if user gives a thumb down.
  repeated Reason reasons = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The additional user comment of the feedback if user gives a thumb
  // down.
  string comment = 3 [(google.api.field_behavior) = OPTIONAL];

  // The related conversation information when user gives feedback.
  ConversationInfo conversation_info = 4;

  // The version of the LLM model that was used to generate the response.
  string llm_model_version = 5;

  // Optional. The UI component the user feedback comes from, which could be
  // GOOGLE_CONSOLE, GOOGLE_WIDGET, GOOGLE_WEBAPP.
  FeedbackSource feedback_source = 6 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The version of the component that this report is being sent from.
  string component_version = 7 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Whether the customer accepted data use terms.
  bool data_terms_accepted = 8 [(google.api.field_behavior) = OPTIONAL];
}
