Skip to content

Commit 6b5d85c

Browse files
Google APIscopybara-github
Google APIs
authored andcommitted
feat: add options of query_source, search_config, end_user_metadata and exact_search
feat: expose metadata in AnswerSource PiperOrigin-RevId: 696328328
1 parent 50d87b4 commit 6b5d85c

File tree

3 files changed

+221
-6
lines changed

3 files changed

+221
-6
lines changed

Diff for: google/cloud/dialogflow/v2beta1/BUILD.bazel

+2-1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ java_gapic_test(
152152
"com.google.cloud.dialogflow.v2beta1.SessionEntityTypesClientTest",
153153
"com.google.cloud.dialogflow.v2beta1.SessionsClientHttpJsonTest",
154154
"com.google.cloud.dialogflow.v2beta1.SessionsClientTest",
155+
"com.google.cloud.dialogflow.v2beta1.SipTrunksClientHttpJsonTest",
156+
"com.google.cloud.dialogflow.v2beta1.SipTrunksClientTest",
155157
"com.google.cloud.dialogflow.v2beta1.VersionsClientHttpJsonTest",
156158
"com.google.cloud.dialogflow.v2beta1.VersionsClientTest",
157159
],
@@ -407,7 +409,6 @@ load(
407409

408410
csharp_proto_library(
409411
name = "dialogflow_csharp_proto",
410-
extra_opts = [],
411412
deps = [":dialogflow_proto"],
412413
)
413414

Diff for: google/cloud/dialogflow/v2beta1/audio_config.proto

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ message SpeechWordInfo {
109109
// phase.
110110
//
111111
// The client provides this configuration in terms of the durations of those
112-
// two phases. The durations are measured in terms of the audio length from
113-
// the start of the input audio.
112+
// two phases. The durations are measured in terms of the audio length from the
113+
// start of the input audio.
114114
//
115115
// The flow goes like below:
116116
//

Diff for: google/cloud/dialogflow/v2beta1/conversation.proto

+217-3
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,20 @@ import "google/cloud/dialogflow/v2beta1/conversation_profile.proto";
2424
import "google/cloud/dialogflow/v2beta1/generator.proto";
2525
import "google/cloud/dialogflow/v2beta1/participant.proto";
2626
import "google/cloud/dialogflow/v2beta1/session.proto";
27+
import "google/protobuf/struct.proto";
2728
import "google/protobuf/timestamp.proto";
2829

29-
option cc_enable_arenas = true;
3030
option csharp_namespace = "Google.Cloud.Dialogflow.V2Beta1";
3131
option go_package = "cloud.google.com/go/dialogflow/apiv2beta1/dialogflowpb;dialogflowpb";
3232
option java_multiple_files = true;
3333
option java_outer_classname = "ConversationProto";
3434
option java_package = "com.google.cloud.dialogflow.v2beta1";
3535
option objc_class_prefix = "DF";
36+
option (google.api.resource_definition) = {
37+
type: "discoveryengine.googleapis.com/DataStore"
38+
pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}"
39+
pattern: "projects/{project}/locations/{location}/dataStores/{data_store}"
40+
};
3641

3742
// Service for managing
3843
// [Conversations][google.cloud.dialogflow.v2beta1.Conversation].
@@ -328,9 +333,9 @@ message CreateConversationRequest {
328333
// Google. Only set it if you cannot wait for the response to return a
329334
// auto-generated one to you.
330335
//
331-
// The conversation ID must be compliant with the regression fomula
336+
// The conversation ID must be compliant with the regression formula
332337
// `[a-zA-Z][a-zA-Z0-9_-]*` with the characters length in range of [3,64].
333-
// If the field is provided, the caller is resposible for
338+
// If the field is provided, the caller is responsible for
334339
// 1. the uniqueness of the ID, otherwise the request will be rejected.
335340
// 2. the consistency for whether to use custom ID or not under a project to
336341
// better ensure uniqueness.
@@ -706,6 +711,183 @@ message GenerateStatelessSuggestionResponse {
706711
// The request message for
707712
// [Conversations.SearchKnowledge][google.cloud.dialogflow.v2beta1.Conversations.SearchKnowledge].
708713
message SearchKnowledgeRequest {
714+
// The source of the query. We use QuerySource to distinguish queries directly
715+
// entered by agents and suggested queries from
716+
// [Participants.SuggestKnowledgeAssist][google.cloud.dialogflow.v2beta1.Participants.SuggestKnowledgeAssist].
717+
// If SUGGESTED_QUERY source is specified, we will treat it as a continuation
718+
// of a SuggestKnowledgeAssist call.
719+
enum QuerySource {
720+
// Unknown query source.
721+
QUERY_SOURCE_UNSPECIFIED = 0;
722+
723+
// The query is from agents.
724+
AGENT_QUERY = 1;
725+
726+
// The query is a suggested query from
727+
// [Participants.SuggestKnowledgeAssist][google.cloud.dialogflow.v2beta1.Participants.SuggestKnowledgeAssist].
728+
SUGGESTED_QUERY = 2;
729+
}
730+
731+
// Configuration specific to search queries with data stores.
732+
message SearchConfig {
733+
// Boost specifications for data stores.
734+
message BoostSpecs {
735+
// Boost specification to boost certain documents.
736+
// A copy of google.cloud.discoveryengine.v1main.BoostSpec, field
737+
// documentation is available at
738+
// https://cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1alpha/BoostSpec
739+
message BoostSpec {
740+
// Boost applies to documents which match a condition.
741+
message ConditionBoostSpec {
742+
// Specification for custom ranking based on customer specified
743+
// attribute
744+
// value. It provides more controls for customized ranking than the
745+
// simple (condition, boost) combination above.
746+
message BoostControlSpec {
747+
// The attribute(or function) for which the custom ranking is to be
748+
// applied.
749+
enum AttributeType {
750+
// Unspecified AttributeType.
751+
ATTRIBUTE_TYPE_UNSPECIFIED = 0;
752+
753+
// The value of the numerical field will be used to dynamically
754+
// update the boost amount. In this case, the attribute_value (the
755+
// x value) of the control point will be the actual value of the
756+
// numerical field for which the boost_amount is specified.
757+
NUMERICAL = 1;
758+
759+
// For the freshness use case the attribute value will be the
760+
// duration between the current time and the date in the datetime
761+
// field specified. The value must be formatted as an XSD
762+
// `dayTimeDuration` value (a restricted subset of an ISO 8601
763+
// duration value). The pattern for this is:
764+
// `[nD][T[nH][nM][nS]]`. E.g. `5D`, `3DT12H30M`, `T24H`.
765+
FRESHNESS = 2;
766+
}
767+
768+
// The interpolation type to be applied. Default will be linear
769+
// (Piecewise Linear).
770+
enum InterpolationType {
771+
// Interpolation type is unspecified. In this case, it defaults to
772+
// Linear.
773+
INTERPOLATION_TYPE_UNSPECIFIED = 0;
774+
775+
// Piecewise linear interpolation will be applied.
776+
LINEAR = 1;
777+
}
778+
779+
// The control points used to define the curve. The curve defined
780+
// through these control points can only be monotonically increasing
781+
// or decreasing(constant values are acceptable).
782+
message ControlPoint {}
783+
784+
// Optional. The name of the field whose value will be used to
785+
// determine the boost amount.
786+
string field_name = 1 [(google.api.field_behavior) = OPTIONAL];
787+
788+
// Optional. The attribute type to be used to determine the boost
789+
// amount. The attribute value can be derived from the field value
790+
// of the specified field_name. In the case of numerical it is
791+
// straightforward i.e. attribute_value = numerical_field_value. In
792+
// the case of freshness however, attribute_value = (time.now() -
793+
// datetime_field_value).
794+
AttributeType attribute_type = 2
795+
[(google.api.field_behavior) = OPTIONAL];
796+
797+
// Optional. The interpolation type to be applied to connect the
798+
// control points listed below.
799+
InterpolationType interpolation_type = 3
800+
[(google.api.field_behavior) = OPTIONAL];
801+
802+
// Optional. The control points used to define the curve. The
803+
// monotonic function (defined through the interpolation_type above)
804+
// passes through the control points listed here.
805+
repeated ControlPoint control_points = 4
806+
[(google.api.field_behavior) = OPTIONAL];
807+
}
808+
809+
// Optional. An expression which specifies a boost condition. The
810+
// syntax and supported fields are the same as a filter expression.
811+
// Examples:
812+
//
813+
// * To boost documents with document ID "doc_1" or "doc_2", and
814+
// color
815+
// "Red" or "Blue":
816+
// * (id: ANY("doc_1", "doc_2")) AND (color: ANY("Red","Blue"))
817+
string condition = 1 [(google.api.field_behavior) = OPTIONAL];
818+
819+
// Optional. Strength of the condition boost, which should be in [-1,
820+
// 1]. Negative boost means demotion. Default is 0.0.
821+
//
822+
// Setting to 1.0 gives the document a big promotion. However, it does
823+
// not necessarily mean that the boosted document will be the top
824+
// result at all times, nor that other documents will be excluded.
825+
// Results could still be shown even when none of them matches the
826+
// condition. And results that are significantly more relevant to the
827+
// search query can still trump your heavily favored but irrelevant
828+
// documents.
829+
//
830+
// Setting to -1.0 gives the document a big demotion. However, results
831+
// that are deeply relevant might still be shown. The document will
832+
// have an upstream battle to get a fairly high ranking, but it is not
833+
// blocked out completely.
834+
//
835+
// Setting to 0.0 means no boost applied. The boosting condition is
836+
// ignored.
837+
float boost = 2 [(google.api.field_behavior) = OPTIONAL];
838+
839+
// Optional. Complex specification for custom ranking based on
840+
// customer defined attribute value.
841+
BoostControlSpec boost_control_spec = 4
842+
[(google.api.field_behavior) = OPTIONAL];
843+
}
844+
845+
// Optional. Condition boost specifications. If a document matches
846+
// multiple conditions in the specifictions, boost scores from these
847+
// specifications are all applied and combined in a non-linear way.
848+
// Maximum number of specifications is 20.
849+
repeated ConditionBoostSpec condition_boost_specs = 1
850+
[(google.api.field_behavior) = OPTIONAL];
851+
}
852+
853+
// Optional. Data Stores where the boosting configuration is applied. The
854+
// full names of the referenced data stores. Formats:
855+
// `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`
856+
// `projects/{project}/locations/{location}/dataStores/{data_store}`
857+
repeated string data_stores = 1 [
858+
(google.api.field_behavior) = OPTIONAL,
859+
(google.api.resource_reference) = {
860+
type: "discoveryengine.googleapis.com/DataStore"
861+
}
862+
];
863+
864+
// Optional. A list of boosting specifications.
865+
repeated BoostSpec spec = 2 [(google.api.field_behavior) = OPTIONAL];
866+
}
867+
868+
// Filter specification for data store queries.
869+
message FilterSpecs {
870+
// Optional. The data store where the filter configuration is applied.
871+
// Full resource name of data store, such as
872+
// projects/{project}/locations/{location}/collections/{collectionId}/
873+
// dataStores/{dataStoreId}.
874+
repeated string data_stores = 1 [(google.api.field_behavior) = OPTIONAL];
875+
876+
// Optional. The filter expression to be applied.
877+
// Expression syntax is documented at
878+
// https://cloud.google.com/generative-ai-app-builder/docs/filter-search-metadata#filter-expression-syntax
879+
string filter = 2 [(google.api.field_behavior) = OPTIONAL];
880+
}
881+
882+
// Optional. Boost specifications for data stores.
883+
repeated BoostSpecs boost_specs = 1
884+
[(google.api.field_behavior) = OPTIONAL];
885+
886+
// Optional. Filter specification for data store queries.
887+
repeated FilterSpecs filter_specs = 2
888+
[(google.api.field_behavior) = OPTIONAL];
889+
}
890+
709891
// Required. The parent resource contains the conversation profile
710892
// Format: 'projects/<Project ID>' or `projects/<Project
711893
// ID>/locations/<Location ID>`.
@@ -753,6 +935,35 @@ message SearchKnowledgeRequest {
753935
type: "dialogflow.googleapis.com/Message"
754936
}
755937
];
938+
939+
// Optional. The source of the query in the request.
940+
QuerySource query_source = 7 [(google.api.field_behavior) = OPTIONAL];
941+
942+
// Optional. Information about the end-user to improve the relevance and
943+
// accuracy of generative answers.
944+
//
945+
// This will be interpreted and used by a language model, so, for good
946+
// results, the data should be self-descriptive, and in a simple structure.
947+
//
948+
// Example:
949+
//
950+
// ```json
951+
// {
952+
// "subscription plan": "Business Premium Plus",
953+
// "devices owned": [
954+
// {"model": "Google Pixel 7"},
955+
// {"model": "Google Pixel Tablet"}
956+
// ]
957+
// }
958+
// ```
959+
google.protobuf.Struct end_user_metadata = 9
960+
[(google.api.field_behavior) = OPTIONAL];
961+
962+
// Optional. Configuration specific to search queries with data stores.
963+
SearchConfig search_config = 11 [(google.api.field_behavior) = OPTIONAL];
964+
965+
// Optional. Whether to search the query exactly without query rewrite.
966+
bool exact_search = 14 [(google.api.field_behavior) = OPTIONAL];
756967
}
757968

758969
// The response message for
@@ -793,6 +1004,9 @@ message SearchKnowledgeAnswer {
7931004

7941005
// The relevant snippet of the article.
7951006
string snippet = 3;
1007+
1008+
// Metadata associated with the article.
1009+
google.protobuf.Struct metadata = 5;
7961010
}
7971011

7981012
// The piece of text from the knowledge base documents that answers

0 commit comments

Comments
 (0)