#include "components/omnibox/browser/autocomplete_scoring_model_handler.h"
#include <cmath>
#include <memory>
#include <optional>
#include "base/logging.h"
#include "base/memory/scoped_refptr.h"
#include "base/task/sequenced_task_runner.h"
#include "components/omnibox/browser/autocomplete_scoring_model_executor.h"
#include "components/optimization_guide/core/model_handler.h"
#include "components/optimization_guide/core/optimization_guide_model_provider.h"
#include "components/optimization_guide/proto/autocomplete_scoring_model_metadata.pb.h"
#include "components/optimization_guide/proto/models.pb.h"
#include "third_party/metrics_proto/omnibox_scoring_signals.pb.h"
ModelInput;
ModelOutput;
ScoringSignals;
AutocompleteScoringModelMetadata;
OptimizationTarget;
ScoringSignalSpec;
ScoringSignalTransformation;
constexpr float kDefaultMissingValue = …;
constexpr float kSecondsInDay = …;
namespace {
bool IsValidSignal(float val, const ScoringSignalSpec& signal_spec) { … }
float TransformSignal(float val, ScoringSignalTransformation transformation) { … }
}
AutocompleteScoringModelHandler::AutocompleteScoringModelHandler(
optimization_guide::OptimizationGuideModelProvider* model_provider,
scoped_refptr<base::SequencedTaskRunner> model_executor_task_runner,
std::unique_ptr<AutocompleteScoringModelExecutor> model_executor,
OptimizationTarget optimization_target,
const std::optional<optimization_guide::proto::Any>& model_metadata)
: … { … }
AutocompleteScoringModelHandler::~AutocompleteScoringModelHandler() = default;
std::optional<std::vector<float>>
AutocompleteScoringModelHandler::GetModelInput(
const ScoringSignals& scoring_signals) { … }
std::optional<std::vector<std::vector<float>>>
AutocompleteScoringModelHandler::GetBatchModelInput(
const std::vector<const ScoringSignals*>& scoring_signals_vec) { … }
std::vector<float>
AutocompleteScoringModelHandler::ExtractInputFromScoringSignals(
const ScoringSignals& scoring_signals,
const AutocompleteScoringModelMetadata& metadata) { … }