FinishReason
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct FinishReason : DecodableProtoEnum, Hashable, Sendable
A value enumerating possible reasons for a model to terminate a content generation request.
-
Natural stop point of the model or provided stop sequence.
Declaration
Swift
public static let stop: FinishReason
-
The maximum number of tokens as specified in the request was reached.
Declaration
Swift
public static let maxTokens: FinishReason
-
The token generation was stopped because the response was flagged for safety reasons.
Note
When streaming, the
content
will be empty if content filters blocked the output.Declaration
Swift
public static let safety: FinishReason
-
The token generation was stopped because the response was flagged for unauthorized citations.
Declaration
Swift
public static let recitation: FinishReason
-
All other reasons that stopped token generation.
Declaration
Swift
public static let other: FinishReason
-
Token generation was stopped because the response contained forbidden terms.
Declaration
Swift
public static let blocklist: FinishReason
-
Token generation was stopped because the response contained potentially prohibited content.
Declaration
Swift
public static let prohibitedContent: FinishReason
-
Token generation was stopped because of Sensitive Personally Identifiable Information (SPII).
Declaration
Swift
public static let spii: FinishReason
-
Token generation was stopped because the function call generated by the model was invalid.
Declaration
Swift
public static let malformedFunctionCall: FinishReason
-
Returns the raw string representation of the
FinishReason
value.Note
This value directly corresponds to the values in the REST API.
Declaration
Swift
public let rawValue: String