Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [dialogflow] add options of query_source, search_config, end_user_metadata and exact_search #5813

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ message SpeechWordInfo {
// phase.
//
// The client provides this configuration in terms of the durations of those
// two phases. The durations are measured in terms of the audio length from
// the start of the input audio.
// two phases. The durations are measured in terms of the audio length from the
// start of the input audio.
//
// The flow goes like below:
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,20 @@ import "google/cloud/dialogflow/v2beta1/conversation_profile.proto";
import "google/cloud/dialogflow/v2beta1/generator.proto";
import "google/cloud/dialogflow/v2beta1/participant.proto";
import "google/cloud/dialogflow/v2beta1/session.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";

option cc_enable_arenas = true;
option csharp_namespace = "Google.Cloud.Dialogflow.V2Beta1";
option go_package = "cloud.google.com/go/dialogflow/apiv2beta1/dialogflowpb;dialogflowpb";
option java_multiple_files = true;
option java_outer_classname = "ConversationProto";
option java_package = "com.google.cloud.dialogflow.v2beta1";
option objc_class_prefix = "DF";
option (google.api.resource_definition) = {
type: "discoveryengine.googleapis.com/DataStore"
pattern: "projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}"
pattern: "projects/{project}/locations/{location}/dataStores/{data_store}"
};

// Service for managing
// [Conversations][google.cloud.dialogflow.v2beta1.Conversation].
Expand Down Expand Up @@ -328,9 +333,9 @@ message CreateConversationRequest {
// Google. Only set it if you cannot wait for the response to return a
// auto-generated one to you.
//
// The conversation ID must be compliant with the regression fomula
// The conversation ID must be compliant with the regression formula
// `[a-zA-Z][a-zA-Z0-9_-]*` with the characters length in range of [3,64].
// If the field is provided, the caller is resposible for
// If the field is provided, the caller is responsible for
// 1. the uniqueness of the ID, otherwise the request will be rejected.
// 2. the consistency for whether to use custom ID or not under a project to
// better ensure uniqueness.
Expand Down Expand Up @@ -706,6 +711,183 @@ message GenerateStatelessSuggestionResponse {
// The request message for
// [Conversations.SearchKnowledge][google.cloud.dialogflow.v2beta1.Conversations.SearchKnowledge].
message SearchKnowledgeRequest {
// The source of the query. We use QuerySource to distinguish queries directly
// entered by agents and suggested queries from
// [Participants.SuggestKnowledgeAssist][google.cloud.dialogflow.v2beta1.Participants.SuggestKnowledgeAssist].
// If SUGGESTED_QUERY source is specified, we will treat it as a continuation
// of a SuggestKnowledgeAssist call.
enum QuerySource {
// Unknown query source.
QUERY_SOURCE_UNSPECIFIED = 0;

// The query is from agents.
AGENT_QUERY = 1;

// The query is a suggested query from
// [Participants.SuggestKnowledgeAssist][google.cloud.dialogflow.v2beta1.Participants.SuggestKnowledgeAssist].
SUGGESTED_QUERY = 2;
}

// Configuration specific to search queries with data stores.
message SearchConfig {
// Boost specifications for data stores.
message BoostSpecs {
// Boost specification to boost certain documents.
// A copy of google.cloud.discoveryengine.v1main.BoostSpec, field
// documentation is available at
// https://cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1alpha/BoostSpec
message BoostSpec {
// Boost applies to documents which match a condition.
message ConditionBoostSpec {
// Specification for custom ranking based on customer specified
// attribute
// value. It provides more controls for customized ranking than the
// simple (condition, boost) combination above.
message BoostControlSpec {
// The attribute(or function) for which the custom ranking is to be
// applied.
enum AttributeType {
// Unspecified AttributeType.
ATTRIBUTE_TYPE_UNSPECIFIED = 0;

// The value of the numerical field will be used to dynamically
// update the boost amount. In this case, the attribute_value (the
// x value) of the control point will be the actual value of the
// numerical field for which the boost_amount is specified.
NUMERICAL = 1;

// For the freshness use case the attribute value will be the
// duration between the current time and the date in the datetime
// field specified. The value must be formatted as an XSD
// `dayTimeDuration` value (a restricted subset of an ISO 8601
// duration value). The pattern for this is:
// `[nD][T[nH][nM][nS]]`. E.g. `5D`, `3DT12H30M`, `T24H`.
FRESHNESS = 2;
}

// The interpolation type to be applied. Default will be linear
// (Piecewise Linear).
enum InterpolationType {
// Interpolation type is unspecified. In this case, it defaults to
// Linear.
INTERPOLATION_TYPE_UNSPECIFIED = 0;

// Piecewise linear interpolation will be applied.
LINEAR = 1;
}

// The control points used to define the curve. The curve defined
// through these control points can only be monotonically increasing
// or decreasing(constant values are acceptable).
message ControlPoint {}

// Optional. The name of the field whose value will be used to
// determine the boost amount.
string field_name = 1 [(google.api.field_behavior) = OPTIONAL];

// Optional. The attribute type to be used to determine the boost
// amount. The attribute value can be derived from the field value
// of the specified field_name. In the case of numerical it is
// straightforward i.e. attribute_value = numerical_field_value. In
// the case of freshness however, attribute_value = (time.now() -
// datetime_field_value).
AttributeType attribute_type = 2
[(google.api.field_behavior) = OPTIONAL];

// Optional. The interpolation type to be applied to connect the
// control points listed below.
InterpolationType interpolation_type = 3
[(google.api.field_behavior) = OPTIONAL];

// Optional. The control points used to define the curve. The
// monotonic function (defined through the interpolation_type above)
// passes through the control points listed here.
repeated ControlPoint control_points = 4
[(google.api.field_behavior) = OPTIONAL];
}

// Optional. An expression which specifies a boost condition. The
// syntax and supported fields are the same as a filter expression.
// Examples:
//
// * To boost documents with document ID "doc_1" or "doc_2", and
// color
// "Red" or "Blue":
// * (id: ANY("doc_1", "doc_2")) AND (color: ANY("Red","Blue"))
string condition = 1 [(google.api.field_behavior) = OPTIONAL];

// Optional. Strength of the condition boost, which should be in [-1,
// 1]. Negative boost means demotion. Default is 0.0.
//
// Setting to 1.0 gives the document a big promotion. However, it does
// not necessarily mean that the boosted document will be the top
// result at all times, nor that other documents will be excluded.
// Results could still be shown even when none of them matches the
// condition. And results that are significantly more relevant to the
// search query can still trump your heavily favored but irrelevant
// documents.
//
// Setting to -1.0 gives the document a big demotion. However, results
// that are deeply relevant might still be shown. The document will
// have an upstream battle to get a fairly high ranking, but it is not
// blocked out completely.
//
// Setting to 0.0 means no boost applied. The boosting condition is
// ignored.
float boost = 2 [(google.api.field_behavior) = OPTIONAL];

// Optional. Complex specification for custom ranking based on
// customer defined attribute value.
BoostControlSpec boost_control_spec = 4
[(google.api.field_behavior) = OPTIONAL];
}

// Optional. Condition boost specifications. If a document matches
// multiple conditions in the specifictions, boost scores from these
// specifications are all applied and combined in a non-linear way.
// Maximum number of specifications is 20.
repeated ConditionBoostSpec condition_boost_specs = 1
[(google.api.field_behavior) = OPTIONAL];
}

// Optional. Data Stores where the boosting configuration is applied. The
// full names of the referenced data stores. Formats:
// `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`
// `projects/{project}/locations/{location}/dataStores/{data_store}`
repeated string data_stores = 1 [
(google.api.field_behavior) = OPTIONAL,
(google.api.resource_reference) = {
type: "discoveryengine.googleapis.com/DataStore"
}
];

// Optional. A list of boosting specifications.
repeated BoostSpec spec = 2 [(google.api.field_behavior) = OPTIONAL];
}

// Filter specification for data store queries.
message FilterSpecs {
// Optional. The data store where the filter configuration is applied.
// Full resource name of data store, such as
// projects/{project}/locations/{location}/collections/{collectionId}/
// dataStores/{dataStoreId}.
repeated string data_stores = 1 [(google.api.field_behavior) = OPTIONAL];

// Optional. The filter expression to be applied.
// Expression syntax is documented at
// https://cloud.google.com/generative-ai-app-builder/docs/filter-search-metadata#filter-expression-syntax
string filter = 2 [(google.api.field_behavior) = OPTIONAL];
}

// Optional. Boost specifications for data stores.
repeated BoostSpecs boost_specs = 1
[(google.api.field_behavior) = OPTIONAL];

// Optional. Filter specification for data store queries.
repeated FilterSpecs filter_specs = 2
[(google.api.field_behavior) = OPTIONAL];
}

// Required. The parent resource contains the conversation profile
// Format: 'projects/<Project ID>' or `projects/<Project
// ID>/locations/<Location ID>`.
Expand Down Expand Up @@ -753,6 +935,35 @@ message SearchKnowledgeRequest {
type: "dialogflow.googleapis.com/Message"
}
];

// Optional. The source of the query in the request.
QuerySource query_source = 7 [(google.api.field_behavior) = OPTIONAL];

// Optional. Information about the end-user to improve the relevance and
// accuracy of generative answers.
//
// This will be interpreted and used by a language model, so, for good
// results, the data should be self-descriptive, and in a simple structure.
//
// Example:
//
// ```json
// {
// "subscription plan": "Business Premium Plus",
// "devices owned": [
// {"model": "Google Pixel 7"},
// {"model": "Google Pixel Tablet"}
// ]
// }
// ```
google.protobuf.Struct end_user_metadata = 9
[(google.api.field_behavior) = OPTIONAL];

// Optional. Configuration specific to search queries with data stores.
SearchConfig search_config = 11 [(google.api.field_behavior) = OPTIONAL];

// Optional. Whether to search the query exactly without query rewrite.
bool exact_search = 14 [(google.api.field_behavior) = OPTIONAL];
}

// The response message for
Expand Down Expand Up @@ -793,6 +1004,9 @@ message SearchKnowledgeAnswer {

// The relevant snippet of the article.
string snippet = 3;

// Metadata associated with the article.
google.protobuf.Struct metadata = 5;
}

// The piece of text from the knowledge base documents that answers
Expand Down
Loading
Loading