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