1// Copyright 2023 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.cloud.dialogflow.cx.v3;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/api/resource.proto";
23import "google/protobuf/duration.proto";
24import "google/protobuf/empty.proto";
25import "google/protobuf/field_mask.proto";
26import "google/protobuf/timestamp.proto";
27
28option cc_enable_arenas = true;
29option csharp_namespace = "Google.Cloud.Dialogflow.Cx.V3";
30option go_package = "cloud.google.com/go/dialogflow/cx/apiv3/cxpb;cxpb";
31option java_multiple_files = true;
32option java_outer_classname = "ExperimentProto";
33option java_package = "com.google.cloud.dialogflow.cx.v3";
34option objc_class_prefix = "DF";
35option ruby_package = "Google::Cloud::Dialogflow::CX::V3";
36
37// Service for managing [Experiments][google.cloud.dialogflow.cx.v3.Experiment].
38service Experiments {
39  option (google.api.default_host) = "dialogflow.googleapis.com";
40  option (google.api.oauth_scopes) =
41      "https://www.googleapis.com/auth/cloud-platform,"
42      "https://www.googleapis.com/auth/dialogflow";
43
44  // Returns the list of all experiments in the specified
45  // [Environment][google.cloud.dialogflow.cx.v3.Environment].
46  rpc ListExperiments(ListExperimentsRequest)
47      returns (ListExperimentsResponse) {
48    option (google.api.http) = {
49      get: "/v3/{parent=projects/*/locations/*/agents/*/environments/*}/experiments"
50    };
51    option (google.api.method_signature) = "parent";
52  }
53
54  // Retrieves the specified
55  // [Experiment][google.cloud.dialogflow.cx.v3.Experiment].
56  rpc GetExperiment(GetExperimentRequest) returns (Experiment) {
57    option (google.api.http) = {
58      get: "/v3/{name=projects/*/locations/*/agents/*/environments/*/experiments/*}"
59    };
60    option (google.api.method_signature) = "name";
61  }
62
63  // Creates an [Experiment][google.cloud.dialogflow.cx.v3.Experiment] in the
64  // specified [Environment][google.cloud.dialogflow.cx.v3.Environment].
65  rpc CreateExperiment(CreateExperimentRequest) returns (Experiment) {
66    option (google.api.http) = {
67      post: "/v3/{parent=projects/*/locations/*/agents/*/environments/*}/experiments"
68      body: "experiment"
69    };
70    option (google.api.method_signature) = "parent,experiment";
71  }
72
73  // Updates the specified
74  // [Experiment][google.cloud.dialogflow.cx.v3.Experiment].
75  rpc UpdateExperiment(UpdateExperimentRequest) returns (Experiment) {
76    option (google.api.http) = {
77      patch: "/v3/{experiment.name=projects/*/locations/*/agents/*/environments/*/experiments/*}"
78      body: "experiment"
79    };
80    option (google.api.method_signature) = "experiment,update_mask";
81  }
82
83  // Deletes the specified
84  // [Experiment][google.cloud.dialogflow.cx.v3.Experiment].
85  rpc DeleteExperiment(DeleteExperimentRequest)
86      returns (google.protobuf.Empty) {
87    option (google.api.http) = {
88      delete: "/v3/{name=projects/*/locations/*/agents/*/environments/*/experiments/*}"
89    };
90    option (google.api.method_signature) = "name";
91  }
92
93  // Starts the specified
94  // [Experiment][google.cloud.dialogflow.cx.v3.Experiment]. This rpc only
95  // changes the state of experiment from PENDING to RUNNING.
96  rpc StartExperiment(StartExperimentRequest) returns (Experiment) {
97    option (google.api.http) = {
98      post: "/v3/{name=projects/*/locations/*/agents/*/environments/*/experiments/*}:start"
99      body: "*"
100    };
101    option (google.api.method_signature) = "name";
102  }
103
104  // Stops the specified [Experiment][google.cloud.dialogflow.cx.v3.Experiment].
105  // This rpc only changes the state of experiment from RUNNING to DONE.
106  rpc StopExperiment(StopExperimentRequest) returns (Experiment) {
107    option (google.api.http) = {
108      post: "/v3/{name=projects/*/locations/*/agents/*/environments/*/experiments/*}:stop"
109      body: "*"
110    };
111    option (google.api.method_signature) = "name";
112  }
113}
114
115// Represents an experiment in an environment.
116message Experiment {
117  option (google.api.resource) = {
118    type: "dialogflow.googleapis.com/Experiment"
119    pattern: "projects/{project}/locations/{location}/agents/{agent}/environments/{environment}/experiments/{experiment}"
120  };
121
122  // The state of the experiment.
123  enum State {
124    // State unspecified.
125    STATE_UNSPECIFIED = 0;
126
127    // The experiment is created but not started yet.
128    DRAFT = 1;
129
130    // The experiment is running.
131    RUNNING = 2;
132
133    // The experiment is done.
134    DONE = 3;
135
136    // The experiment with auto-rollout enabled has failed.
137    ROLLOUT_FAILED = 4;
138  }
139
140  // Definition of the experiment.
141  message Definition {
142    // The condition defines which subset of sessions are selected for
143    // this experiment. If not specified, all sessions are eligible. E.g.
144    // "query_input.language_code=en" See the [conditions
145    // reference](https://cloud.google.com/dialogflow/cx/docs/reference/condition).
146    string condition = 1;
147
148    // The variants of the experiment. We currently only support single variant
149    // experiment.
150    oneof variants {
151      // The flow versions as the variants of this experiment.
152      VersionVariants version_variants = 2;
153    }
154  }
155
156  // The inference result which includes an objective metric to optimize and the
157  // confidence interval.
158  message Result {
159    // Types of ratio-based metric for Dialogflow experiment.
160    enum MetricType {
161      // Metric unspecified.
162      METRIC_UNSPECIFIED = 0;
163
164      // Percentage of contained sessions without user calling back in 24 hours.
165      CONTAINED_SESSION_NO_CALLBACK_RATE = 1;
166
167      // Percentage of sessions that were handed to a human agent.
168      LIVE_AGENT_HANDOFF_RATE = 2;
169
170      // Percentage of sessions with the same user calling back.
171      CALLBACK_SESSION_RATE = 3;
172
173      // Percentage of sessions where user hung up.
174      ABANDONED_SESSION_RATE = 4;
175
176      // Percentage of sessions reached Dialogflow 'END_PAGE' or
177      // 'END_SESSION'.
178      SESSION_END_RATE = 5;
179    }
180
181    // Types of count-based metric for Dialogflow experiment.
182    enum CountType {
183      // Count type unspecified.
184      COUNT_TYPE_UNSPECIFIED = 0;
185
186      // Total number of occurrences of a 'NO_MATCH'.
187      TOTAL_NO_MATCH_COUNT = 1;
188
189      // Total number of turn counts.
190      TOTAL_TURN_COUNT = 2;
191
192      // Average turn count in a session.
193      AVERAGE_TURN_COUNT = 3;
194    }
195
196    // A confidence interval is a range of possible values for the experiment
197    // objective you are trying to measure.
198    message ConfidenceInterval {
199      // The confidence level used to construct the interval, i.e. there is X%
200      // chance that the true value is within this interval.
201      double confidence_level = 1;
202
203      // The percent change between an experiment metric's value and the value
204      // for its control.
205      double ratio = 2;
206
207      // Lower bound of the interval.
208      double lower_bound = 3;
209
210      // Upper bound of the interval.
211      double upper_bound = 4;
212    }
213
214    // Metric and corresponding confidence intervals.
215    message Metric {
216      // Ratio-based metric type. Only one of type or count_type is specified in
217      // each Metric.
218      MetricType type = 1;
219
220      // Count-based metric type. Only one of type or count_type is specified in
221      // each Metric.
222      CountType count_type = 5;
223
224      // The actual value of the metric.
225      oneof value {
226        // Ratio value of a metric.
227        double ratio = 2;
228
229        // Count value of a metric.
230        double count = 4;
231      }
232
233      // The probability that the treatment is better than all other treatments
234      // in the experiment
235      ConfidenceInterval confidence_interval = 3;
236    }
237
238    // Version variant and associated metrics.
239    message VersionMetrics {
240      // The name of the flow [Version][google.cloud.dialogflow.cx.v3.Version].
241      // Format: `projects/<Project ID>/locations/<Location
242      // ID>/agents/<Agent ID>/flows/<Flow ID>/versions/<Version ID>`.
243      string version = 1 [(google.api.resource_reference) = {
244        type: "dialogflow.googleapis.com/Version"
245      }];
246
247      // The metrics and corresponding confidence intervals in the inference
248      // result.
249      repeated Metric metrics = 2;
250
251      // Number of sessions that were allocated to this version.
252      int32 session_count = 3;
253    }
254
255    // Version variants and metrics.
256    repeated VersionMetrics version_metrics = 1;
257
258    // The last time the experiment's stats data was updated. Will have default
259    // value if stats have never been computed for this experiment.
260    google.protobuf.Timestamp last_update_time = 2;
261  }
262
263  // The name of the experiment.
264  // Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent
265  // ID>/environments/<Environment ID>/experiments/<Experiment ID>..
266  string name = 1;
267
268  // Required. The human-readable name of the experiment (unique in an
269  // environment). Limit of 64 characters.
270  string display_name = 2 [(google.api.field_behavior) = REQUIRED];
271
272  // The human-readable description of the experiment.
273  string description = 3;
274
275  // The current state of the experiment.
276  // Transition triggered by Experiments.StartExperiment: DRAFT->RUNNING.
277  // Transition triggered by Experiments.CancelExperiment: DRAFT->DONE or
278  // RUNNING->DONE.
279  State state = 4;
280
281  // The definition of the experiment.
282  Definition definition = 5;
283
284  // The configuration for auto rollout. If set, there should be exactly two
285  // variants in the experiment (control variant being the default version of
286  // the flow), the traffic allocation for the non-control variant will
287  // gradually increase to 100% when conditions are met, and eventually
288  // replace the control variant to become the default version of the flow.
289  RolloutConfig rollout_config = 14;
290
291  // State of the auto rollout process.
292  RolloutState rollout_state = 15;
293
294  // The reason why rollout has failed. Should only be set when state is
295  // ROLLOUT_FAILED.
296  string rollout_failure_reason = 16;
297
298  // Inference result of the experiment.
299  Result result = 6;
300
301  // Creation time of this experiment.
302  google.protobuf.Timestamp create_time = 7;
303
304  // Start time of this experiment.
305  google.protobuf.Timestamp start_time = 8;
306
307  // End time of this experiment.
308  google.protobuf.Timestamp end_time = 9;
309
310  // Last update time of this experiment.
311  google.protobuf.Timestamp last_update_time = 10;
312
313  // Maximum number of days to run the experiment/rollout. If auto-rollout is
314  // not enabled, default value and maximum will be 30 days. If auto-rollout is
315  // enabled, default value and maximum will be 6 days.
316  google.protobuf.Duration experiment_length = 11;
317
318  // The history of updates to the experiment variants.
319  repeated VariantsHistory variants_history = 12;
320}
321
322// A list of flow version variants.
323message VersionVariants {
324  // A single flow version with specified traffic allocation.
325  message Variant {
326    // The name of the flow version.
327    // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
328    // ID>/flows/<Flow ID>/versions/<Version ID>`.
329    string version = 1;
330
331    // Percentage of the traffic which should be routed to this
332    // version of flow. Traffic allocation for a single flow must sum up to 1.0.
333    float traffic_allocation = 2;
334
335    // Whether the variant is for the control group.
336    bool is_control_group = 3;
337  }
338
339  // A list of flow version variants.
340  repeated Variant variants = 1;
341}
342
343// The history of variants update.
344message VariantsHistory {
345  // The variants updated. We currently only support single variant
346  // experiment.
347  oneof variants {
348    // The flow versions as the variants.
349    VersionVariants version_variants = 1;
350  }
351
352  // Update time of the variants.
353  google.protobuf.Timestamp update_time = 2;
354}
355
356// The configuration for auto rollout.
357message RolloutConfig {
358  // A single rollout step with specified traffic allocation.
359  message RolloutStep {
360    // The name of the rollout step;
361    string display_name = 1;
362
363    // The percentage of traffic allocated to the flow version of this rollout
364    // step. (0%, 100%].
365    int32 traffic_percent = 2;
366
367    // The minimum time that this step should last. Should be longer than 1
368    // hour. If not set, the default minimum duration for each step will be 1
369    // hour.
370    google.protobuf.Duration min_duration = 3;
371  }
372
373  // Steps to roll out a flow version. Steps should be sorted by percentage in
374  // ascending order.
375  repeated RolloutStep rollout_steps = 1;
376
377  // The conditions that are used to evaluate the success of a rollout
378  // step. If not specified, all rollout steps will proceed to the next one
379  // unless failure conditions are met. E.g. "containment_rate > 60% AND
380  // callback_rate < 20%". See the [conditions
381  // reference](https://cloud.google.com/dialogflow/cx/docs/reference/condition).
382  string rollout_condition = 2;
383
384  // The conditions that are used to evaluate the failure of a rollout
385  // step. If not specified, no rollout steps will fail. E.g. "containment_rate
386  // < 10% OR average_turn_count < 3". See the [conditions
387  // reference](https://cloud.google.com/dialogflow/cx/docs/reference/condition).
388  string failure_condition = 3;
389}
390
391// State of the auto-rollout process.
392message RolloutState {
393  // Display name of the current auto rollout step.
394  string step = 1;
395
396  // Index of the current step in the auto rollout steps list.
397  int32 step_index = 3;
398
399  // Start time of the current step.
400  google.protobuf.Timestamp start_time = 2;
401}
402
403// The request message for
404// [Experiments.ListExperiments][google.cloud.dialogflow.cx.v3.Experiments.ListExperiments].
405message ListExperimentsRequest {
406  // Required. The [Environment][google.cloud.dialogflow.cx.v3.Environment] to
407  // list all environments for. Format: `projects/<Project
408  // ID>/locations/<Location ID>/agents/<Agent ID>/environments/<Environment
409  // ID>`.
410  string parent = 1 [
411    (google.api.field_behavior) = REQUIRED,
412    (google.api.resource_reference) = {
413      child_type: "dialogflow.googleapis.com/Experiment"
414    }
415  ];
416
417  // The maximum number of items to return in a single page. By default 20 and
418  // at most 100.
419  int32 page_size = 2;
420
421  // The next_page_token value returned from a previous list request.
422  string page_token = 3;
423}
424
425// The response message for
426// [Experiments.ListExperiments][google.cloud.dialogflow.cx.v3.Experiments.ListExperiments].
427message ListExperimentsResponse {
428  // The list of experiments. There will be a maximum number of items
429  // returned based on the page_size field in the request. The list may in some
430  // cases be empty or contain fewer entries than page_size even if this isn't
431  // the last page.
432  repeated Experiment experiments = 1;
433
434  // Token to retrieve the next page of results, or empty if there are no more
435  // results in the list.
436  string next_page_token = 2;
437}
438
439// The request message for
440// [Experiments.GetExperiment][google.cloud.dialogflow.cx.v3.Experiments.GetExperiment].
441message GetExperimentRequest {
442  // Required. The name of the
443  // [Environment][google.cloud.dialogflow.cx.v3.Environment]. Format:
444  // `projects/<Project ID>/locations/<Location ID>/agents/<Agent
445  // ID>/environments/<Environment ID>/experiments/<Experiment ID>`.
446  string name = 1 [
447    (google.api.field_behavior) = REQUIRED,
448    (google.api.resource_reference) = {
449      type: "dialogflow.googleapis.com/Experiment"
450    }
451  ];
452}
453
454// The request message for
455// [Experiments.CreateExperiment][google.cloud.dialogflow.cx.v3.Experiments.CreateExperiment].
456message CreateExperimentRequest {
457  // Required. The [Agent][google.cloud.dialogflow.cx.v3.Agent] to create an
458  // [Environment][google.cloud.dialogflow.cx.v3.Environment] for. Format:
459  // `projects/<Project ID>/locations/<Location ID>/agents/<Agent
460  // ID>/environments/<Environment ID>`.
461  string parent = 1 [
462    (google.api.field_behavior) = REQUIRED,
463    (google.api.resource_reference) = {
464      child_type: "dialogflow.googleapis.com/Experiment"
465    }
466  ];
467
468  // Required. The experiment to create.
469  Experiment experiment = 2 [(google.api.field_behavior) = REQUIRED];
470}
471
472// The request message for
473// [Experiments.UpdateExperiment][google.cloud.dialogflow.cx.v3.Experiments.UpdateExperiment].
474message UpdateExperimentRequest {
475  // Required. The experiment to update.
476  Experiment experiment = 1 [(google.api.field_behavior) = REQUIRED];
477
478  // Required. The mask to control which fields get updated.
479  google.protobuf.FieldMask update_mask = 2
480      [(google.api.field_behavior) = REQUIRED];
481}
482
483// The request message for
484// [Experiments.DeleteExperiment][google.cloud.dialogflow.cx.v3.Experiments.DeleteExperiment].
485message DeleteExperimentRequest {
486  // Required. The name of the
487  // [Environment][google.cloud.dialogflow.cx.v3.Environment] to delete. Format:
488  // `projects/<Project ID>/locations/<Location ID>/agents/<Agent
489  // ID>/environments/<Environment ID>/experiments/<Experiment ID>`.
490  string name = 1 [
491    (google.api.field_behavior) = REQUIRED,
492    (google.api.resource_reference) = {
493      type: "dialogflow.googleapis.com/Experiment"
494    }
495  ];
496}
497
498// The request message for
499// [Experiments.StartExperiment][google.cloud.dialogflow.cx.v3.Experiments.StartExperiment].
500message StartExperimentRequest {
501  // Required. Resource name of the experiment to start.
502  // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
503  // ID>/environments/<Environment ID>/experiments/<Experiment ID>`.
504  string name = 1 [
505    (google.api.field_behavior) = REQUIRED,
506    (google.api.resource_reference) = {
507      type: "dialogflow.googleapis.com/Experiment"
508    }
509  ];
510}
511
512// The request message for
513// [Experiments.StopExperiment][google.cloud.dialogflow.cx.v3.Experiments.StopExperiment].
514message StopExperimentRequest {
515  // Required. Resource name of the experiment to stop.
516  // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
517  // ID>/environments/<Environment ID>/experiments/<Experiment ID>`.
518  string name = 1 [
519    (google.api.field_behavior) = REQUIRED,
520    (google.api.resource_reference) = {
521      type: "dialogflow.googleapis.com/Experiment"
522    }
523  ];
524}
525