#include "components/optimization_guide/core/model_execution/safety_config.h"
#include <cstddef>
#include <optional>
#include <string>
#include "base/containers/contains.h"
#include "base/no_destructor.h"
#include "components/optimization_guide/core/model_execution/substitution.h"
#include "components/optimization_guide/core/optimization_guide_features.h"
#include "components/optimization_guide/proto/string_value.pb.h"
#include "components/optimization_guide/proto/substitution.pb.h"
#include "components/optimization_guide/proto/text_safety_model_metadata.pb.h"
#include "services/on_device_model/public/mojom/on_device_model.mojom.h"
namespace optimization_guide {
namespace {
RepeatedPtrField;
bool HasUnsafeScores(
const RepeatedPtrField<proto::SafetyCategoryThreshold>& thresholds,
const on_device_model::mojom::SafetyInfoPtr& safety_info) { … }
CheckTemplate;
CheckTemplate MakeDefaultRawOutputCheckTemplate() { … }
const CheckTemplate& GetRawOutputCheckTemplate(
const proto::FeatureTextSafetyConfiguration& config) { … }
}
SafetyConfig::SafetyConfig() = default;
SafetyConfig::SafetyConfig(
std::optional<proto::FeatureTextSafetyConfiguration> proto)
: … { … }
SafetyConfig::SafetyConfig(SafetyConfig&&) = default;
SafetyConfig::~SafetyConfig() = default;
SafetyConfig& SafetyConfig::operator=(SafetyConfig&&) = default;
uint32_t SafetyConfig::TokenInterval() const { … }
bool SafetyConfig::IsTextInUnsupportedOrUndeterminedLanguage(
const on_device_model::mojom::SafetyInfoPtr& safety_info) const { … }
bool SafetyConfig::IsUnsafeText(
const on_device_model::mojom::SafetyInfoPtr& safety_info) const { … }
int SafetyConfig::NumRequestChecks() const { … }
std::optional<SubstitutionResult> SafetyConfig::GetRequestCheckInput(
int check_idx,
const google::protobuf::MessageLite& message) const { … }
bool SafetyConfig::IsRequestCheckLanguageOnly(int check_idx) const { … }
bool SafetyConfig::ShouldIgnoreLanguageResultForRequestCheck(
int check_idx) const { … }
bool SafetyConfig::IsRequestUnsafe(
int check_idx,
const on_device_model::mojom::SafetyInfoPtr& safety_info) const { … }
bool SafetyConfig::HasRawOutputCheck() const { … }
std::optional<SubstitutionResult> SafetyConfig::GetRawOutputCheckInput(
const std::string& raw_output) const { … }
}