1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568
|
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_OPTIMIZATION_GUIDE_CORE_OPTIMIZATION_GUIDE_FEATURES_H_
#define COMPONENTS_OPTIMIZATION_GUIDE_CORE_OPTIMIZATION_GUIDE_FEATURES_H_
#include <map>
#include <optional>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "base/component_export.h"
#include "base/containers/enum_set.h"
#include "base/containers/flat_set.h"
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/optimization_guide/core/optimization_guide_enums.h"
#include "components/optimization_guide/proto/hints.pb.h"
#include "components/optimization_guide/proto/model_execution.pb.h"
#include "components/optimization_guide/proto/models.pb.h"
#include "net/nqe/effective_connection_type.h"
#include "url/gurl.h"
namespace optimization_guide {
class MqlsFeatureMetadata;
namespace features {
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kOptimizationHints);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kRemoteOptimizationGuideFetching);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kOptimizationGuideFetchingForSRP);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kOptimizationTargetPrediction);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kOptimizationGuideModelDownloading);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kPageTextExtraction);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kPushNotifications);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kOptimizationGuideMetadataValidation);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kPreventLongRunningPredictionModels);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kOverrideNumThreadsForModelExecution);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kOptGuideEnableXNNPACKDelegateWithTFLite);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kOptimizationGuidePersonalizedFetching);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kOptimizationGuidePredictionModelKillswitch);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kOptimizationGuideModelExecution);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kOptimizationGuideOnDeviceModel);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kOptimizationGuideComposeOnDeviceEval);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kModelQualityLogging);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kLogOnDeviceMetricsOnStartup);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kTextSafetyClassifier);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kTextSafetyScanLanguageDetection);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kOnDeviceModelValidation);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kOnDeviceModelFetchPerformanceClassEveryStartup);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kAiSettingsPageForceAvailable);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kPrivacyGuideAiSettings);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kAnnotatedPageContentWithActionableElements);
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kOptimizationGuideProactivePersonalizedHintsFetching);
// Allows setting feature params for model download configuration, such as
// minimum performance class for download.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kOnDeviceModelPerformanceParams);
// Comma-separated list of performance classes (e.g. "3,4,5") that should
// download the base model. Use "*" if there is no performance class
// requirement.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
extern const base::FeatureParam<std::string>
kPerformanceClassListForOnDeviceModel;
// Comma-separated list of performance classes that should use a smaller model
// if available. This should be a subset of
// kPerformanceClassListForOnDeviceModel.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
extern const base::FeatureParam<std::string>
kLowTierPerformanceClassListForOnDeviceModel;
// Comma-separated list of performance classes that have image input enabled.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
extern const base::FeatureParam<std::string> kPerformanceClassListForImageInput;
// Comma-separated list of performance classes that have audio input enabled.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
extern const base::FeatureParam<std::string> kPerformanceClassListForAudioInput;
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kOptimizationGuideIconView);
// Whether model sessions may be brokered to untrusted processes.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kBrokerModelSessionsForUntrustedProcesses);
typedef base::EnumSet<proto::RequestContext,
proto::RequestContext_MIN,
proto::RequestContext_MAX>
RequestContextSet;
typedef base::EnumSet<proto::OptimizationType,
proto::OptimizationType_MIN,
proto::OptimizationType_MAX>
OptimizationTypeSet;
// The grace period duration for how long to give outstanding page text dump
// requests to respond after DidFinishLoad.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta PageTextExtractionOutstandingRequestsGracePeriod();
// Whether hints for active tabs and top hosts should be batch updated.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool ShouldBatchUpdateHintsForActiveTabsAndTopHosts();
// The maximum number of hosts allowed to be requested by the client to the
// remote Optimization Guide Service.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
size_t MaxHostsForOptimizationGuideServiceHintsFetch();
// The maximum number of URLs allowed to be requested by the client to the
// remote Optimization Guide Service.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
size_t MaxUrlsForOptimizationGuideServiceHintsFetch();
// Whether hints fetching for search results is enabled.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool IsSRPFetchingEnabled();
// The maximum number of search results allowed to be requested by the client to
// the remote Optimization Guide Service.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
size_t MaxResultsForSRPFetch();
// The maximum number of hosts allowed to be stored as covered by the hints
// fetcher.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
size_t MaxHostsForRecordingSuccessfullyCovered();
// The amount of time a fetched hint will be considered fresh enough
// to be used and remain in the OptimizationGuideStore.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta StoredFetchedHintsFreshnessDuration();
// The API key for the One Platform Optimization Guide Service.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
std::string GetOptimizationGuideServiceAPIKey();
// The host for the One Platform Optimization Guide Service for hints.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
GURL GetOptimizationGuideServiceGetHintsURL();
// The host for the One Platform Optimization Guide Service for Models and Host
// Model Features.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
GURL GetOptimizationGuideServiceGetModelsURL();
// Whether prediction of optimization targets is enabled.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool IsOptimizationTargetPredictionEnabled();
// Whether server optimization hints are enabled.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool IsOptimizationHintsEnabled();
// Returns true if the feature to fetch from the remote Optimization Guide
// Service is enabled. This controls the fetching of both hints and models.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool IsRemoteFetchingEnabled();
// Returns true if the feature to use push notifications is enabled.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool IsPushNotificationsEnabled();
// The maximum data byte size for a server-provided bloom filter. This is
// a client-side safety limit for RAM use in case server sends too large of
// a bloom filter.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
int MaxServerBloomFilterByteSize();
// Returns the duration of the time window before hints expiration during which
// the hosts should be refreshed. Example: If the hints for a host expire at
// time T, then they are eligible for refresh at T -
// GetHostHintsFetchRefreshDuration().
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta GetHostHintsFetchRefreshDuration();
// Returns the duration of the time window between fetches for hints for the
// URLs opened in active tabs.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta GetActiveTabsFetchRefreshDuration();
// Returns the max duration since the time a tab has to be shown to be
// considered active for a hints refresh.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta GetActiveTabsStalenessTolerance();
// Returns the max number of concurrent fetches to the remote Optimization Guide
// Service that should be allowed for batch updates
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
size_t MaxConcurrentBatchUpdateFetches();
// Returns the max number of concurrent fetches to the remote Optimization Guide
// Service that should be allowed for navigations.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
size_t MaxConcurrentPageNavigationFetches();
// Returns the minimum random delay before starting to fetch for hints for
// active tabs.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta ActiveTabsHintsFetchRandomMinDelay();
// Returns the maximum random delay before starting to fetch for hints for
// active tabs.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta ActiveTabsHintsFetchRandomMaxDelay();
// Returns whether fetching hints for active tabs should happen on deferred
// startup. Otherwise active tabs hints will be fetched after a random interval
// between ActiveTabsHintsFetchRandomMinDelay() and
// ActiveTabsHintsFetchRandomMaxDelay().
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool ShouldDeferStartupActiveTabsHintsFetch();
// The amount of time host model features will be considered fresh enough
// to be used and remain in the OptimizationGuideStore.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta StoredHostModelFeaturesFreshnessDuration();
// The maximum duration for which models can remain in the
// OptimizationGuideStore without being loaded.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta StoredModelsValidDuration();
// The amount of time URL-keyed hints within the hint cache will be
// allowed to be used and not be purged.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta URLKeyedHintValidCacheDuration();
// The maximum number of hosts allowed to be requested by the client to the
// remote Optimization Guide Service for use by prediction models.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
size_t MaxHostsForOptimizationGuideServiceModelsFetch();
// The maximum number of hosts allowed to be maintained in a least-recently-used
// cache by the prediction manager.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
size_t MaxHostModelFeaturesCacheSize();
// The maximum number of hints allowed to be maintained in a least-recently-used
// cache for hosts.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
size_t MaxHostKeyedHintCacheSize();
// The maximum number of hints allowed to be maintained in a least-recently-used
// cache for URLs.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
size_t MaxURLKeyedHintCacheSize();
// Returns true if hints should be persisted to disk. If this is false, hints
// will just be stored in-memory and evicted if not recently used.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool ShouldPersistHintsToDisk();
// Returns true if the optimization target decision for |optimization_target|
// should not be propagated to the caller in an effort to fully understand the
// statistics for the served model and not taint the resulting data.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool ShouldOverrideOptimizationTargetDecisionForMetricsPurposes(
proto::OptimizationTarget optimization_target);
// Returns requests contexts for which personalized metadata should be enabled.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
RequestContextSet GetAllowedContextsForPersonalizedMetadata();
// Returns optimization types for which proactive personalization should be
// enabled.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
OptimizationTypeSet GetAllowedOptimizationTypesForProactivePersonalization();
// Returns the minimum random delay before starting to fetch for prediction
// models and host model features.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta PredictionModelFetchRandomMinDelay();
// Returns the maximum random delay before starting to fetch for prediction
// models and host model features.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta PredictionModelFetchRandomMaxDelay();
// Returns the time to wait before retrying a failed fetch for prediction
// models.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta PredictionModelFetchRetryDelay();
// Returns the time to wait after browser start before fetching prediciton
// models.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta PredictionModelFetchStartupDelay();
// Returns the time to wait after a successful fetch of prediction models to
// refresh models.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta PredictionModelFetchInterval();
// Returns the random delay time to wait for starting a model fetch when a new
// optimization target observer registration happens, after the initial model
// fetch is completed.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta PredictionModelNewRegistrationFetchRandomDelay();
// Whether to use the model execution watchdog.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool IsModelExecutionWatchdogEnabled();
// The default timeout for the watchdog to use if none is given by the caller.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta ModelExecutionWatchdogDefaultTimeout();
// Whether the ability to download models is enabled.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool IsModelDownloadingEnabled();
// Returns whether unrestricted model downloading is enabled. If true, the
// client should download models using highest priority.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool IsUnrestrictedModelDownloadingEnabled();
// Returns whether the page entities model should be executed on page content
// for a user using |locale| as their browser language.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool ShouldExecutePageEntitiesModelOnPageContent(const std::string& locale);
// The time to wait beyond the onload event before sending the hints request for
// link predictions.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta GetOnloadDelayForHintsFetching();
// Returns whether the metadata validation fetch feature is host keyed.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool ShouldMetadataValidationFetchHostKeyed();
// Returns the number of threads to use for model inference on the given
// optimization target.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
std::optional<int> OverrideNumThreadsForOptTarget(
proto::OptimizationTarget opt_target);
// Whether XNNPACK should be used with TFLite, on platforms where it is
// supported. This is a no-op on unsupported platforms.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool TFLiteXNNPACKDelegateEnabled();
// Whether logging of model quality is enabled.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool IsModelQualityLoggingEnabled();
// Whether model quality logging is enabled for a feature.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool IsModelQualityLoggingEnabledForFeature(const MqlsFeatureMetadata*);
// Returns whether the `model_version` for `opt_target` is part of emergency
// killswitch, and this model should be stopped serving immediately.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
std::map<proto::OptimizationTarget, std::set<int64_t>>
GetPredictionModelVersionsInKillSwitch();
// Returns whether the on-device config should be loaded with higher priority.
// If true, all tasks for the on-device model execution config interpreter
// will be run with user visible priority.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool ShouldLoadOnDeviceModelExecutionConfigWithHigherPriority();
// Returns the idle timeout before the on device model service shuts down.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta GetOnDeviceModelIdleTimeout();
// Returns the delay before starting the on device model inference when
// running validation.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta GetOnDeviceModelExecutionValidationStartupDelay();
// These params determine how context processing works for the on device model.
// The model will process at least min tokens before responding. While waiting
// for the ExecuteModel() call, up to max tokens will be processed in chunks of
// the given size.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
int GetOnDeviceModelMinTokensForContext();
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
int GetOnDeviceModelMaxTokensForContext();
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
int GetOnDeviceModelContextTokenChunkSize();
// The maximum tokens for the input when executing the model.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
int GetOnDeviceModelMaxTokensForExecute();
// The maximum tokens the model will output if the maximum input is given.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
int GetOnDeviceModelMaxTokensForOutput();
// The maximum total tokens, for input and output combined.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
uint32_t GetOnDeviceModelMaxTokens();
// Returns the number of crashes without a successful response before the
// on-device model won't be used.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
int GetOnDeviceModelCrashCountBeforeDisable();
// Feature params for handling exponential backoff after crashes.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta GetOnDeviceModelMaxCrashBackoffTime();
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta GetOnDeviceModelCrashBackoffBaseTime();
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta GetOnDeviceStartupMetricDelay();
// Returns true if during execution a disconnect is received (which generally
// means a crash) the message should be sent to the server for processing.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool GetOnDeviceFallbackToServerOnDisconnect();
// Whether any features are enabled that allow launching the on-device
// service.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool CanLaunchOnDeviceModelService();
// Whether on-device execution is enabled.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool IsOnDeviceExecutionEnabled();
// The amount of grace period to use from the last time the feature was used to
// consider it as recently used. Recent usage is one of the criteria for the
// base and adaptation on-device models to be downloaded.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta GetOnDeviceEligibleModelFeatureRecentUsePeriod();
// The on-device model is fetched when the device is considered eligible for
// on-device execution. When the device stops being eligible, the model is
// retained for this amount of time. This protects the user from repeatedly
// downloading the model in the event eligibility fluctuates. for on-device
// evaluation
// See on_device_model_component.cc for how eligibility is computed.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta GetOnDeviceModelRetentionTime();
// Return the disk space (in MiB) required for on device model install.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
int GetDiskSpaceRequiredInMbForOnDeviceModelInstall();
// Whether there is enough free disk space to allow on-device model
// installation.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool IsFreeDiskSpaceSufficientForOnDeviceModelInstall(
int64_t free_disk_space_bytes);
// Whether there is too little disk space to retain the on-device model
// installation.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool IsFreeDiskSpaceTooLowForOnDeviceModelInstall(
int64_t free_disk_space_bytes);
// Returns true if unsafe content should be removed.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool GetOnDeviceModelRetractUnsafeContent();
// Whether we should initiate download of the text safety classifier model.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool ShouldUseTextSafetyClassifierModel();
// This is the minimum required reliability threshold for language detection to
// be considered reliable enough for the text safety classifier. Clamped to the
// range [0, 1].
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
double GetOnDeviceModelLanguageDetectionMinimumReliability();
// These params configure the repetition checker. See HasRepeatingSuffix() in
// repetition_checker.h for explanation. A value of 2 for num repeats and 16 for
// min repeat chars would mean we will halt a response once it repeats at least
// 16 chars 2 times at the end of the response.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
int GetOnDeviceModelNumRepeats();
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
int GetOnDeviceModelMinRepeatChars();
// Whether the response should be retracted if repeats are detected.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool GetOnDeviceModelRetractRepeats();
// Settings to control output sampling.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
int GetOnDeviceModelDefaultTopK();
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
int GetOnDeviceModelMaxTopK();
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
double GetOnDeviceModelDefaultTemperature();
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
std::vector<uint32_t> GetOnDeviceModelAllowedAdaptationRanks();
// Whether the on-device model should be limited to running only on the CPU.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool ForceCpuBackendForOnDeviceModel();
// Whether the on-device model will be validated when updated using a set of
// prompts with expected output.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool IsOnDeviceModelValidationEnabled();
// Whether on-device sessions should be blocked on validation failures.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool ShouldOnDeviceModelBlockOnValidationFailure();
// Whether the validation result for a model should be cleared if Chrome's
// version changes.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool ShouldOnDeviceModelClearValidationOnVersionChange();
// The delay from when a new model is received (or startup if validation has not
// completed) until the validation is run.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
base::TimeDelta GetOnDeviceModelValidationDelay();
// The maximum number of attempts model validation will be retried.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
int GetOnDeviceModelValidationAttemptCount();
// Returns whether the icon view should be enabled.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool ShouldEnableOptimizationGuideIconView();
// Whether Ai settings page integration with Privacy Guide is enabled.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
bool IsPrivacyGuideAiSettingsEnabled();
// Whether policy-disabled AI settings are visible.
COMPONENT_EXPORT(OPTIMIZATION_GUIDE_FEATURES)
BASE_DECLARE_FEATURE(kAiSettingsPageEnterpriseDisabledUi);
} // namespace features
} // namespace optimization_guide
#endif // COMPONENTS_OPTIMIZATION_GUIDE_CORE_OPTIMIZATION_GUIDE_FEATURES_H_
|