validate method

void validate()

Throws an ArgumentError for a value no engine can sample with, as core's SamplingParams.validate does.

Implementation

void validate() {
  final t = temperature;
  if (t != null && !(t >= 0 && t.isFinite)) {
    throw ArgumentError.value(t, 'temperature', 'must be 0 or more');
  }
  final k = topK;
  if (k != null && k < 1) {
    throw ArgumentError.value(k, 'topK', 'must be 1 or more');
  }
  final p = topP;
  if (p != null && !(p > 0 && p <= 1)) {
    throw ArgumentError.value(p, 'topP', 'must be above 0 and at most 1');
  }
}