chromium/components/optimization_guide/core/optimization_guide_model_executor.h

// Copyright 2023 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_MODEL_EXECUTOR_H_
#define COMPONENTS_OPTIMIZATION_GUIDE_CORE_OPTIMIZATION_GUIDE_MODEL_EXECUTOR_H_

#include "base/functional/callback_forward.h"
#include "base/memory/raw_ptr.h"
#include "base/observer_list_types.h"
#include "base/types/expected.h"
#include "components/optimization_guide/core/model_execution/feature_keys.h"
#include "components/optimization_guide/core/model_execution/optimization_guide_model_execution_error.h"
#include "components/optimization_guide/core/model_quality/model_quality_log_entry.h"
#include "components/optimization_guide/proto/model_execution.pb.h"

namespace optimization_guide {

// The result type of model execution.
OptimizationGuideModelExecutionResult;

// A response type used for OptimizationGuideModelExecutor::Session.
struct StreamingResponse {};

struct OptimizationGuideModelStreamingExecutionResult {};

// The callback for receiving the model execution result and model quality log
// entry.
OptimizationGuideModelExecutionResultCallback;

// A callback for receiving a score from the model, or nullopt if the model
// is not running.
OptimizationGuideModelScoreCallback;

// The callback for receiving streamed output from the model. The log entry will
// be null until `StreamingResponse.is_complete` is true.
OptimizationGuideModelExecutionResultStreamingCallback;

// The callback for receiving the token size of the given input.
OptimizationGuideModelSizeInTokenCallback;

// Params used to control sampling output tokens for the on-device model.
struct SamplingParams {};

// Params to control model config per-session.
struct SessionConfigParams {};

// Reasons why the on-device model was not available for use.
//
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class OnDeviceModelEligibilityReason {};

// Observer that is notified when the on-device model availability changes for
// the on-device eligible features.
class OnDeviceModelAvailabilityObserver : public base::CheckedObserver {};

// The model's configured limits on tokens.
struct TokenLimits {};

// Interface for model execution.
class OptimizationGuideModelExecutor {};

}  // namespace optimization_guide

#endif  // COMPONENTS_OPTIMIZATION_GUIDE_CORE_OPTIMIZATION_GUIDE_MODEL_EXECUTOR_H_