Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vertex AI] Cleanup Decodable impl from BlockThreshold #13673

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions FirebaseVertexAI/Sources/Safety.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ public struct SafetySetting {

/// Block at and beyond a specified ``SafetyRating/HarmProbability``.
public enum BlockThreshold: String, Sendable {
/// Unknown. A new server value that isn't recognized by the SDK.
case unknown = "UNKNOWN"

/// Threshold is unspecified.
case unspecified = "HARM_BLOCK_THRESHOLD_UNSPECIFIED"

// Content with `.negligible` will be allowed.
case blockLowAndAbove = "BLOCK_LOW_AND_ABOVE"

Expand Down Expand Up @@ -160,19 +154,7 @@ extension SafetySetting.HarmCategory: Codable {
}

@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
extension SafetySetting.BlockThreshold: Encodable {
public init(from decoder: Decoder) throws {
let value = try decoder.singleValueContainer().decode(String.self)
guard let decodedThreshold = SafetySetting.BlockThreshold(rawValue: value) else {
Logging.default
.error("[FirebaseVertexAI] Unrecognized BlockThreshold with value \"\(value)\".")
self = .unknown
return
}

self = decodedThreshold
}
}
extension SafetySetting.BlockThreshold: Encodable {}

@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
extension SafetySetting: Encodable {}
Loading