#include "components/optimization_guide/core/model_execution/on_device_model_feature_adapter.h"
#include <optional>
#include <string>
#include "base/metrics/histogram_functions.h"
#include "base/strings/strcat.h"
#include "base/timer/elapsed_timer.h"
#include "base/types/expected.h"
#include "components/optimization_guide/core/model_execution/on_device_model_execution_proto_descriptors.h"
#include "components/optimization_guide/core/model_execution/on_device_model_execution_proto_value_utils.h"
#include "components/optimization_guide/core/model_execution/redactor.h"
#include "components/optimization_guide/core/model_execution/response_parser.h"
#include "components/optimization_guide/core/model_execution/response_parser_registry.h"
#include "components/optimization_guide/core/model_execution/simple_response_parser.h"
#include "components/optimization_guide/core/optimization_guide_constants.h"
#include "components/optimization_guide/core/optimization_guide_features.h"
#include "components/optimization_guide/core/optimization_guide_util.h"
namespace optimization_guide {
OnDeviceModelFeatureAdapter::OnDeviceModelFeatureAdapter(
proto::OnDeviceModelExecutionFeatureConfig&& config)
: … { … }
OnDeviceModelFeatureAdapter::~OnDeviceModelFeatureAdapter() = default;
std::string OnDeviceModelFeatureAdapter::GetStringToCheckForRedacting(
const google::protobuf::MessageLite& message) const { … }
std::optional<SubstitutionResult>
OnDeviceModelFeatureAdapter::ConstructInputString(
const google::protobuf::MessageLite& request,
bool want_input_context) const { … }
RedactResult OnDeviceModelFeatureAdapter::Redact(
const google::protobuf::MessageLite& last_message,
std::string& current_response) const { … }
void OnDeviceModelFeatureAdapter::ParseResponse(
const google::protobuf::MessageLite& request,
const std::string& model_response,
ResponseParser::ResultCallback callback) const { … }
std::optional<proto::TextSafetyRequest>
OnDeviceModelFeatureAdapter::ConstructTextSafetyRequest(
const google::protobuf::MessageLite& request,
const std::string& text) const { … }
std::optional<SamplingParams> OnDeviceModelFeatureAdapter::MaybeSamplingParams()
const { … }
}