// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

edition = "2023";

package optimization_guide.proto;

import "components/optimization_guide/proto/model_quality_metadata.proto";

option optimize_for = LITE_RUNTIME;
option java_package = "org.chromium.components.optimization_guide.features.proto";

option java_outer_classname = "HistoryAnswerProto";

// DO NOT EDIT THIS FILE DIRECTLY!
//
// This file is generated in g3 and then synced to Chrome. Instead, please refer to
// http://go/chrome-mqls-onboarding (Google-internal link), and then changes will
// be synced with Chrome automatically.

// Protos for the AiData representing the History AQA inference flow. The
// request contains the user query and top candidate passages, and
// the response contains the answer and citations.

// Next ID: 6
message HistoryAnswerLoggingData {
  HistoryAnswerRequest request = 1 [features = { field_presence: EXPLICIT }];

  HistoryAnswerResponse response = 2 [features = { field_presence: EXPLICIT }];

  HistoryAnswerQuality quality = 3 [features = { field_presence: EXPLICIT }];

  ModelExecutionInfo model_execution_info = 4 [features = { field_presence: EXPLICIT }];

  reserved 5;
}

// The History AQA request contains a query and top candidate passages.
// Next ID: 3
message HistoryAnswerRequest {
  // The history search query entered by the user.
  string query = 1 [features = { field_presence: EXPLICIT }];

  // Top passage candidates that may contain information to generate answers
  // from.
  repeated Passage passages = 2;
}

// Passage.
// Next ID: 4
message Passage {
  // The text of the passage.
  string text = 1 [features = { field_presence: EXPLICIT }];

  // Id of the passage.
  string passage_id = 3 [features = { field_presence: EXPLICIT }];

  reserved 2;
}

// History AQA answer response.
// Next ID: 3
message HistoryAnswerResponse {
  // Answer contained in the response.
  Answer answer = 1 [features = { field_presence: EXPLICIT }];

  // Whether the request contained an unanswerable question. If true, the
  // `answer` field will be invalid.
  bool is_unanswerable = 2 [features = { field_presence: EXPLICIT }];
}

// AQA answer.
// Next ID: 4
message Answer {
  // Answer text.
  string text = 1 [features = { field_presence: EXPLICIT }];

  // Answerable score.
  float score = 2 [features = { field_presence: EXPLICIT }];

  // Citations of the answer.
  repeated Citation citations = 3;
}

// AQA citation.
// Next ID: 3
message Citation {
  // Passage id from the request.
  string passage_id = 2 [features = { field_presence: EXPLICIT }];

  reserved 1;
}

// Next ID: 3
message HistoryAnswerQuality {
  // The session id of the user query. Use this to join with HistoryAnswer
  // and HistoryQueryQuality protos from the same session.
  string session_id = 1 [features = { field_presence: EXPLICIT }];

  // The URL of the document that the passages belong to. A single
  // HistoryAnswerRequest should contain passages from a single documents.
  string url = 2 [features = { field_presence: EXPLICIT }];
}
