MediaPipeTasksDecision Framework Reference

BooleanQuestion

struct BooleanQuestion: Sendable, Equatable

Configuration for evaluating a natural-language boolean predicate.

  • Creates a new BooleanQuestion instance.

    Declaration

    Swift

    init(condition: String = "", threshold: Float = 0.5, temperature: Float = 0.0, normalizePrior: Bool = false, positiveExamples: [String] = [], negativeExamples: [String] = [], inputPrompt: InputPrompt = .unspecified, fittedHead: Data? = nil)
  • Creates an examples-only BooleanQuestion.

    Throws DecisionMakerError.invalidArgument if either example list is empty, contains an empty string, or threshold is outside [0.0, 1.0].

    Declaration

    Swift

    init(positiveExamples: [String], negativeExamples: [String], inputPrompt: InputPrompt = .unspecified, threshold: Float = 0.5, temperature: Float = 0.0) throws
  • Natural-language condition statement to evaluate as true or false.

    May be empty when both positiveExamples and negativeExamples are provided, or when fittedHead is provided.

    Declaration

    Swift

    var condition: String
  • Optional pre-fitted FittedHead binary payload for embedding models.

    Declaration

    Swift

    var fittedHead: Data?
  • How examples and inputs are embedded when examples are provided.

    Declaration

    Swift

    var inputPrompt: InputPrompt
  • Example inputs that should evaluate to false.

    Must be provided together with positiveExamples. Supported only by embedding models; other models throw DecisionMakerError.failedToEvaluate.

    Declaration

    Swift

    var negativeExamples: [String]
  • Whether to subtract the empty-context prior log-odds before thresholding.

    Cannot be true when examples or fittedHead are provided (DecisionMakerError.invalidArgument).

    Declaration

    Swift

    var normalizePrior: Bool
  • Example inputs that should evaluate to true.

    Must be provided together with negativeExamples. Supported only by embedding models; other models throw DecisionMakerError.failedToEvaluate.

    Declaration

    Swift

    var positiveExamples: [String]
  • Softmax temperature override (0.0 uses the model's calibrated default).

    Declaration

    Swift

    var temperature: Float
  • Probability threshold in [0.0, 1.0] above which BooleanResult.value is true.

    Declaration

    Swift

    var threshold: Float