CategoryScores
ModerationsResult.swift:60struct CategoryScores
struct CategoryScores
s6OpenAI17ModerationsResultV10ModerationV14CategoryScoresV
What are these?5C0XR
import OpenAI
struct Moderation
struct ModerationsResult
init(from decoder: any Decoder) throws
let categories: Categories
Collection of per-category binary usage policies violation flags. For each category, the value is true if the model flags the corresponding category as violated, false otherwise.
let categoryScores: CategoryScores
Collection of per-category raw scores output by the model, denoting the model’s confidence that the input violates the OpenAI’s policy for the category. The value is between 0 and 1, where higher values denote higher confidence. The scores should not be interpreted as probabilities.
let flagged: Bool
True if the model classifies the content as violating OpenAI’s usage policies, false otherwise.
struct Categories
protocol Decodable
A type that can decode itself from an external representation.
protocol Encodable
A type that can encode itself to an external representation.
protocol Equatable
A type that can be compared for value equality.
protocol Sequence<Element>
A type that provides sequential, iterated access to its elements.
init(from decoder: any Decoder) throws
let harassment: Double
Content that expresses, incites, or promotes harassing language towards any target.
let harassmentThreatening: Double
Harassment content that also includes violence or serious harm towards any target.
let hate: Double
Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste.
let hateThreatening: Double
Hateful content that also includes violence or serious harm towards the targeted group.
let selfHarm: Double
Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.
let selfHarmInstructions: Double
Content that encourages performing acts of self-harm, such as suicide, cutting, and eating disorders, or that gives instructions or advice on how to commit such acts.
let selfHarmIntent: Double
Content where the speaker expresses that they are engaging or intend to engage in acts of self-harm, such as suicide, cutting, and eating disorders.
let sexual: Double
Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).
let sexualMinors: Double
Sexual content that includes an individual who is under 18 years old.
let violence: Double
Content that promotes or glorifies violence or celebrates the suffering or humiliation of others.
let violenceGraphic: Double
Violent content that depicts death, violence, or serious physical injury in extreme graphic detail.
func makeIterator() -> IndexingIterator<[(String, Bool)]>
enum CodingKeys
var lazy: LazySequence<Self> { get }
A sequence containing the same elements as this sequence, but on which some operations, such as map
and filter
, are implemented lazily.
var underestimatedCount: Int { get }
A value less than or equal to the number of elements in the sequence, calculated nondestructively.
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.
func allSatisfy(_ predicate: (Self.Element) throws -> Bool) rethrows -> Bool
Returns a Boolean value indicating whether every element of a sequence satisfies a given predicate.
func compactMap<ElementOfResult>(_ transform: (Self.Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult]
Returns an array containing the non-nil
results of calling the given transformation with each element of this sequence.
func compare<Comparator>(_ lhs: Comparator.Compared, _ rhs: Comparator.Compared) -> ComparisonResult where Comparator : SortComparator, Comparator == Self.Element
If lhs
is ordered before rhs
in the ordering described by the given sequence of SortComparator
s
func contains(where predicate: (Self.Element) throws -> Bool) rethrows -> Bool
Returns a Boolean value indicating whether the sequence contains an element that satisfies the given predicate.
func count<E>(where predicate: (Self.Element) throws(E) -> Bool) throws(E) -> Int where E : Error
Returns the number of elements in the sequence that satisfy the given predicate.
func drop(while predicate: (Self.Element) throws -> Bool) rethrows -> DropWhileSequence<Self>
Returns a sequence by skipping the initial, consecutive elements that satisfy the given predicate.
func dropFirst(_ k: Int = 1) -> DropFirstSequence<Self>
Returns a sequence containing all but the given number of initial elements.
func dropLast(_ k: Int = 1) -> [Self.Element]
Returns a sequence containing all but the given number of final elements.
func elementsEqual<OtherSequence>(_ other: OtherSequence, by areEquivalent: (Self.Element, OtherSequence.Element) throws -> Bool) rethrows -> Bool where OtherSequence : Sequence
Returns a Boolean value indicating whether this sequence and another sequence contain equivalent elements in the same order, using the given predicate as the equivalence test.
func enumerated() -> EnumeratedSequence<Self>
Returns a sequence of pairs (n, x), where n represents a consecutive integer starting at zero and x represents an element of the sequence.
func filter(_ isIncluded: (Self.Element) throws -> Bool) rethrows -> [Self.Element]
Returns an array containing, in order, the elements of the sequence that satisfy the given predicate.
func filter(_ predicate: Predicate<Self.Element>) throws -> [Self.Element]
func first(where predicate: (Self.Element) throws -> Bool) rethrows -> Self.Element?
Returns the first element of the sequence that satisfies the given predicate.
func flatMap<SegmentOfResult>(_ transform: (Self.Element) throws -> SegmentOfResult) rethrows -> [SegmentOfResult.Element] where SegmentOfResult : Sequence
Returns an array containing the concatenated results of calling the given transformation with each element of this sequence.
func forEach(_ body: (Self.Element) throws -> Void) rethrows
Calls the given closure on each element in the sequence in the same order as a for
-in
loop.
func formatted<S>(_ style: S) -> S.FormatOutput where Self == S.FormatInput, S : FormatStyle
func lexicographicallyPrecedes<OtherSequence>(_ other: OtherSequence, by areInIncreasingOrder: (Self.Element, Self.Element) throws -> Bool) rethrows -> Bool where OtherSequence : Sequence, Self.Element == OtherSequence.Element
Returns a Boolean value indicating whether the sequence precedes another sequence in a lexicographical (dictionary) ordering, using the given predicate to compare elements.
func map<T, E>(_ transform: (Self.Element) throws(E) -> T) throws(E) -> [T] where E : Error
Returns an array containing the results of mapping the given closure over the sequence’s elements.
@warn_unqualified_access func max(by areInIncreasingOrder: (Self.Element, Self.Element) throws -> Bool) rethrows -> Self.Element?
Returns the maximum element in the sequence, using the given predicate as the comparison between elements.
@warn_unqualified_access func min(by areInIncreasingOrder: (Self.Element, Self.Element) throws -> Bool) rethrows -> Self.Element?
Returns the minimum element in the sequence, using the given predicate as the comparison between elements.
func prefix(_ maxLength: Int) -> PrefixSequence<Self>
Returns a sequence, up to the specified maximum length, containing the initial elements of the sequence.
func prefix(while predicate: (Self.Element) throws -> Bool) rethrows -> [Self.Element]
Returns a sequence containing the initial, consecutive elements that satisfy the given predicate.
func reduce<Result>(_ initialResult: Result, _ nextPartialResult: (Result, Self.Element) throws -> Result) rethrows -> Result
Returns the result of combining the elements of the sequence using the given closure.
func reduce<Result>(into initialResult: Result, _ updateAccumulatingResult: (inout Result, Self.Element) throws -> ()) rethrows -> Result
Returns the result of combining the elements of the sequence using the given closure.
func reversed() -> [Self.Element]
Returns an array containing the elements of this sequence in reverse order.
func shuffled() -> [Self.Element]
Returns the elements of the sequence, shuffled.
func shuffled<T>(using generator: inout T) -> [Self.Element] where T : RandomNumberGenerator
Returns the elements of the sequence, shuffled using the given generator as a source for randomness.
func sorted(by areInIncreasingOrder: (Self.Element, Self.Element) throws -> Bool) rethrows -> [Self.Element]
Returns the elements of the sequence, sorted using the given predicate as the comparison between elements.
func sorted<Comparator>(using comparator: Comparator) -> [Self.Element] where Comparator : SortComparator, Self.Element == Comparator.Compared
Returns the elements of the sequence, sorted using the given comparator to compare elements.
func sorted<S, Comparator>(using comparators: S) -> [Self.Element] where S : Sequence, Comparator : SortComparator, Comparator == S.Element, Self.Element == Comparator.Compared
Returns the elements of the sequence, sorted using the given array of SortComparator
s to compare elements.
func split(maxSplits: Int = Int.max, omittingEmptySubsequences: Bool = true, whereSeparator isSeparator: (Self.Element) throws -> Bool) rethrows -> [ArraySlice<Self.Element>]
Returns the longest possible subsequences of the sequence, in order, that don’t contain elements satisfying the given predicate. Elements that are used to split the sequence are not returned as part of any subsequence.
func starts<PossiblePrefix>(with possiblePrefix: PossiblePrefix, by areEquivalent: (Self.Element, PossiblePrefix.Element) throws -> Bool) rethrows -> Bool where PossiblePrefix : Sequence
Returns a Boolean value indicating whether the initial elements of the sequence are equivalent to the elements in another sequence, using the given predicate as the equivalence test.
func suffix(_ maxLength: Int) -> [Self.Element]
Returns a subsequence, up to the given maximum length, containing the final elements of the sequence.
func withContiguousStorageIfAvailable<R>(_ body: (UnsafeBufferPointer<Self.Element>) throws -> R) rethrows -> R?
func flatMap<ElementOfResult>(_ transform: (Self.Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult]