Skip to content

Commit

Permalink
feat: add answer generation APIs
Browse files Browse the repository at this point in the history
feat: add standalone grounding API
feat: add project provision and terms APIs
fix!: remove some unused LRO metadata/response
docs: keep the API doc up-to-date with recent changes

PiperOrigin-RevId: 624207111
  • Loading branch information
Google APIs authored and Copybara-Service committed Apr 12, 2024
1 parent 7715536 commit 509f002
Show file tree
Hide file tree
Showing 19 changed files with 1,524 additions and 57 deletions.
11 changes: 10 additions & 1 deletion google/cloud/discoveryengine/v1alpha/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ proto_library(
srcs = [
"acl_config.proto",
"acl_config_service.proto",
"answer.proto",
"chunk.proto",
"chunk_service.proto",
"common.proto",
Expand All @@ -41,7 +42,11 @@ proto_library(
"engine.proto",
"engine_service.proto",
"estimate_billing_service.proto",
"grounded_generation_service.proto",
"grounding.proto",
"import_config.proto",
"project.proto",
"project_service.proto",
"purge_config.proto",
"rank_service.proto",
"recommendation_service.proto",
Expand All @@ -51,6 +56,7 @@ proto_library(
"search_tuning_service.proto",
"serving_config.proto",
"serving_config_service.proto",
"session.proto",
"site_search_engine.proto",
"site_search_engine_service.proto",
"user_event.proto",
Expand Down Expand Up @@ -144,6 +150,10 @@ java_gapic_test(
"com.google.cloud.discoveryengine.v1alpha.EngineServiceClientTest",
"com.google.cloud.discoveryengine.v1alpha.EstimateBillingServiceClientHttpJsonTest",
"com.google.cloud.discoveryengine.v1alpha.EstimateBillingServiceClientTest",
"com.google.cloud.discoveryengine.v1alpha.GroundedGenerationServiceClientHttpJsonTest",
"com.google.cloud.discoveryengine.v1alpha.GroundedGenerationServiceClientTest",
"com.google.cloud.discoveryengine.v1alpha.ProjectServiceClientHttpJsonTest",
"com.google.cloud.discoveryengine.v1alpha.ProjectServiceClientTest",
"com.google.cloud.discoveryengine.v1alpha.RankServiceClientHttpJsonTest",
"com.google.cloud.discoveryengine.v1alpha.RankServiceClientTest",
"com.google.cloud.discoveryengine.v1alpha.RecommendationServiceClientHttpJsonTest",
Expand Down Expand Up @@ -406,7 +416,6 @@ load(

csharp_proto_library(
name = "discoveryengine_csharp_proto",
extra_opts = [],
deps = [":discoveryengine_proto"],
)

Expand Down
328 changes: 328 additions & 0 deletions google/cloud/discoveryengine/v1alpha/answer.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,328 @@
// Copyright 2022 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.v1alpha;

import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/timestamp.proto";

option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Alpha";
option go_package = "cloud.google.com/go/discoveryengine/apiv1alpha/discoveryenginepb;discoveryenginepb";
option java_multiple_files = true;
option java_outer_classname = "AnswerProto";
option java_package = "com.google.cloud.discoveryengine.v1alpha";
option objc_class_prefix = "DISCOVERYENGINE";
option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1alpha";
option ruby_package = "Google::Cloud::DiscoveryEngine::V1alpha";

// Defines an answer.
message Answer {
option (google.api.resource) = {
type: "discoveryengine.googleapis.com/Answer"
pattern: "projects/{project}/locations/{location}/dataStores/{data_store}/sessions/{session}/answers/{answer}"
pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/sessions/{session}/answers/{answer}"
pattern: "projects/{project}/locations/{location}/collections/{collection}/engines/{engine}/sessions/{session}/answers/{answer}"
};

// Citation info for a segment.
message Citation {
// Index indicates the start of the segment, measured in bytes (UTF-8
// unicode).
int64 start_index = 1;

// End of the attributed segment, exclusive.
int64 end_index = 2;

// Citation sources for the attributed segment.
repeated CitationSource sources = 3;
}

// Citation source.
message CitationSource {
// ID of the citation source.
string reference_id = 1;
}

// Reference.
message Reference {
// Unstructured document information.
message UnstructuredDocumentInfo {
// Chunk content.
message ChunkContent {
// Chunk textual content.
string content = 1;

// Page identifier.
string page_identifier = 2;
}

// Document resource name.
string document = 1 [(google.api.resource_reference) = {
type: "discoveryengine.googleapis.com/Document"
}];

// URI for the document.
string uri = 2;

// Title.
string title = 3;

// List of cited chunk contents derived from document content.
repeated ChunkContent chunk_contents = 4;
}

// Chunk information.
message ChunkInfo {
// Document metadata.
message DocumentMetadata {
// Document resource name.
string document = 1 [(google.api.resource_reference) = {
type: "discoveryengine.googleapis.com/Document"
}];

// URI for the document.
string uri = 2;

// Title.
string title = 3;

// Page identifier.
string page_identifier = 4;
}

// Chunk resource name.
string chunk = 1 [(google.api.resource_reference) = {
type: "discoveryengine.googleapis.com/Chunk"
}];

// Chunk textual content.
string content = 2;

// Relevance score.
optional float relevance_score = 3;

// Document metadata.
DocumentMetadata document_metadata = 4;
}

// Search result content.
oneof content {
// Unstructured document information.
UnstructuredDocumentInfo unstructured_document_info = 1;

// Chunk information.
ChunkInfo chunk_info = 2;
}
}

// Step information.
message Step {
// Action.
message Action {
// Search action.
message SearchAction {
// The query to search.
string query = 1;
}

// Observation.
message Observation {
message SearchResult {
// Snippet information.
message SnippetInfo {
// Snippet content.
string snippet = 1;

// Status of the snippet defined by the search team.
string snippet_status = 2;
}

// Chunk information.
message ChunkInfo {
// Chunk resource name.
string chunk = 1;

// Chunk textual content.
string content = 2;

// Relevance score.
optional float relevance_score = 3;
}

// Document resource name.
string document = 1;

// URI for the document.
string uri = 2;

// Title.
string title = 3;

// If citation_type is DOCUMENT_LEVEL_CITATION, populate document
// level snippets.
repeated SnippetInfo snippet_info = 4;

// If citation_type is CHUNK_LEVEL_CITATION and chunk mode is on,
// populate chunk info.
repeated ChunkInfo chunk_info = 5;
}

// Search results observed by the search action, it can be snippets info
// or chunk info, depending on the citation type set by the user.
repeated SearchResult search_results = 2;
}

// The action.
oneof action {
// Search action.
SearchAction search_action = 2;
}

// Observation.
Observation observation = 3;
}

// Enumeration of the state of the step.
enum State {
// Unknown.
STATE_UNSPECIFIED = 0;

// Step is currently in progress.
IN_PROGRESS = 1;

// Step currently failed.
FAILED = 2;

// Step has succeeded.
SUCCEEDED = 3;
}

// The state of the step.
State state = 1;

// The description of the step.
string description = 2;

// The thought of the step.
string thought = 3;

// Actions.
repeated Action actions = 4;
}

// Query understanding information.
message QueryUnderstandingInfo {
// Query classification information.
message QueryClassificationInfo {
// Query classification types.
enum Type {
// Unspecified query classification type.
TYPE_UNSPECIFIED = 0;

// Adversarial query classification type.
ADVERSARIAL_QUERY = 1;

// Non-answer-seeking query classification type.
NON_ANSWER_SEEKING_QUERY = 2;
}

// Query classification type.
Type type = 1;

// Classification output.
bool positive = 2;
}

// Query classification information.
repeated QueryClassificationInfo query_classification_info = 1;
}

// Enumeration of the state of the answer generation.
enum State {
// Unknown.
STATE_UNSPECIFIED = 0;

// Answer generation is currently in progress.
IN_PROGRESS = 1;

// Answer generation currently failed.
FAILED = 2;

// Answer generation has succeeded.
SUCCEEDED = 3;
}

// An enum for answer skipped reasons.
enum AnswerSkippedReason {
// Default value. The answer skipped reason is not specified.
ANSWER_SKIPPED_REASON_UNSPECIFIED = 0;

// The adversarial query ignored case.
ADVERSARIAL_QUERY_IGNORED = 1;

// The non-answer seeking query ignored case.
NON_ANSWER_SEEKING_QUERY_IGNORED = 2;

// The out-of-domain query ignored case.
//
// Google skips the answer if there are no high-relevance search results.
OUT_OF_DOMAIN_QUERY_IGNORED = 3;

// The potential policy violation case.
//
// Google skips the answer if there is a potential policy violation
// detected. This includes content that may be violent or toxic.
POTENTIAL_POLICY_VIOLATION = 4;
}

// Immutable. Fully qualified name
// `projects/{project}/locations/global/collections/{collection}/engines/{engine}/sessions/*/answers/*`
string name = 1 [(google.api.field_behavior) = IMMUTABLE];

// The state of the answer generation.
State state = 2;

// The textual answer.
string answer_text = 3;

// Citations.
repeated Citation citations = 4;

// References.
repeated Reference references = 5;

// Suggested related questions.
repeated string related_questions = 6;

// Answer generation steps.
repeated Step steps = 7;

// Query understanding information.
QueryUnderstandingInfo query_understanding_info = 10;

// Additional answer-skipped reasons. This provides the reason for ignored
// cases. If nothing is skipped, this field is not set.
repeated AnswerSkippedReason answer_skipped_reasons = 11;

// Output only. Answer creation timestamp.
google.protobuf.Timestamp create_time = 8
[(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. Answer completed timestamp.
google.protobuf.Timestamp complete_time = 9
[(google.api.field_behavior) = OUTPUT_ONLY];
}
6 changes: 6 additions & 0 deletions google/cloud/discoveryengine/v1alpha/chunk.proto
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ message Chunk {

// Title of the document.
string title = 2;

// Data representation.
// The structured JSON data for the document. It should conform to the
// registered [Schema][google.cloud.discoveryengine.v1alpha.Schema] or an
// `INVALID_ARGUMENT` error is thrown.
google.protobuf.Struct struct_data = 3;
}

// Page span of the chunk.
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/discoveryengine/v1alpha/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ enum SolutionType {
}

// Tiers of search features. Different tiers might have different
// pricing. To learn more, please check the pricing documentation.
// pricing. To learn more, check the pricing documentation.
enum SearchTier {
// Default value when the enum is unspecified. This is invalid to use.
SEARCH_TIER_UNSPECIFIED = 0;
Expand Down

0 comments on commit 509f002

Please sign in to comment.