From 9a5df1bb2c97950de383fc5835d5a8b446ae925b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8A=E3=82=93?= <31785428+rin-senpai@users.noreply.github.com> Date: Sun, 30 Jun 2024 16:44:00 +1000 Subject: [PATCH] Used watchOS 4.0 as a baseline and updated function requirements as such --- Package.swift | 2 +- Sources/GoogleAI/Chat.swift | 6 +++--- Sources/GoogleAI/CountTokensRequest.swift | 12 +++++------ Sources/GoogleAI/Errors.swift | 2 +- Sources/GoogleAI/FunctionCalling.swift | 2 +- Sources/GoogleAI/GenerateContentError.swift | 2 +- Sources/GoogleAI/GenerateContentRequest.swift | 6 +++--- .../GoogleAI/GenerateContentResponse.swift | 20 +++++++++---------- Sources/GoogleAI/GenerationConfig.swift | 6 +++--- Sources/GoogleAI/GenerativeAIRequest.swift | 6 +++--- Sources/GoogleAI/GenerativeAIService.swift | 7 +++++-- Sources/GoogleAI/GenerativeAISwift.swift | 4 ++-- Sources/GoogleAI/GenerativeModel.swift | 8 ++++---- Sources/GoogleAI/JSONValue.swift | 2 +- Sources/GoogleAI/Logging.swift | 2 +- Sources/GoogleAI/ModelContent.swift | 8 ++++---- .../GoogleAI/PartsRepresentable+Image.swift | 10 ++++++---- Sources/GoogleAI/PartsRepresentable.swift | 14 ++++++------- Sources/GoogleAI/Safety.swift | 14 ++++++------- 19 files changed, 69 insertions(+), 64 deletions(-) diff --git a/Package.swift b/Package.swift index 0169b2c..041b6c9 100644 --- a/Package.swift +++ b/Package.swift @@ -23,7 +23,7 @@ let package = Package( .iOS(.v11), .macOS(.v10_13), .macCatalyst(.v13), - .watchOS(.v8) + .watchOS(.v4) ], products: [ .library( diff --git a/Sources/GoogleAI/Chat.swift b/Sources/GoogleAI/Chat.swift index 9c6a6d7..ebb9c65 100644 --- a/Sources/GoogleAI/Chat.swift +++ b/Sources/GoogleAI/Chat.swift @@ -84,7 +84,7 @@ public class Chat { /// and response will be added to the history. If unsuccessful, history will remain unchanged. /// - Parameter parts: The new content to send as a single chat message. /// - Returns: A stream containing the model's response or an error if an error occurred. - @available(macOS 12.0, *) + @available(macOS 12.0, watchOS 8.0, *) public func sendMessageStream(_ parts: any ThrowingPartsRepresentable...) -> AsyncThrowingStream { return try sendMessageStream([ModelContent(parts: parts)]) @@ -94,7 +94,7 @@ public class Chat { /// and response will be added to the history. If unsuccessful, history will remain unchanged. /// - Parameter content: The new content to send as a single chat message. /// - Returns: A stream containing the model's response or an error if an error occurred. - @available(macOS 12.0, *) + @available(macOS 12.0, watchOS 8.0, *) public func sendMessageStream(_ content: @autoclosure () throws -> [ModelContent]) -> AsyncThrowingStream { let resolvedContent: [ModelContent] @@ -188,4 +188,4 @@ public class Chat { return ModelContent(role: "user", parts: content.parts) } } -} +} \ No newline at end of file diff --git a/Sources/GoogleAI/CountTokensRequest.swift b/Sources/GoogleAI/CountTokensRequest.swift index b6d7105..3c5de5f 100644 --- a/Sources/GoogleAI/CountTokensRequest.swift +++ b/Sources/GoogleAI/CountTokensRequest.swift @@ -14,14 +14,14 @@ import Foundation -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) struct CountTokensRequest { let model: String let generateContentRequest: GenerateContentRequest let options: RequestOptions } -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) extension CountTokensRequest: GenerativeAIRequest { typealias Response = CountTokensResponse @@ -31,7 +31,7 @@ extension CountTokensRequest: GenerativeAIRequest { } /// The model's response to a count tokens request. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) public struct CountTokensResponse { /// The total number of tokens in the input given to the model as a prompt. public let totalTokens: Int @@ -39,12 +39,12 @@ public struct CountTokensResponse { // MARK: - Codable Conformances -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) extension CountTokensRequest: Encodable { enum CodingKeys: CodingKey { case generateContentRequest } } -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) -extension CountTokensResponse: Decodable {} +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) +extension CountTokensResponse: Decodable {} \ No newline at end of file diff --git a/Sources/GoogleAI/Errors.swift b/Sources/GoogleAI/Errors.swift index 35e7e6b..d534343 100644 --- a/Sources/GoogleAI/Errors.swift +++ b/Sources/GoogleAI/Errors.swift @@ -186,4 +186,4 @@ enum RPCErrorMessage: String { enum InvalidCandidateError: Error { case emptyContent(underlyingError: Error) case malformedContent(underlyingError: Error) -} +} \ No newline at end of file diff --git a/Sources/GoogleAI/FunctionCalling.swift b/Sources/GoogleAI/FunctionCalling.swift index 57130eb..ca88246 100644 --- a/Sources/GoogleAI/FunctionCalling.swift +++ b/Sources/GoogleAI/FunctionCalling.swift @@ -292,4 +292,4 @@ extension FunctionCallingConfig.Mode: Encodable {} extension ToolConfig: Encodable {} -extension FunctionResponse: Encodable {} +extension FunctionResponse: Encodable {} \ No newline at end of file diff --git a/Sources/GoogleAI/GenerateContentError.swift b/Sources/GoogleAI/GenerateContentError.swift index 2d6a5be..63f18b2 100644 --- a/Sources/GoogleAI/GenerateContentError.swift +++ b/Sources/GoogleAI/GenerateContentError.swift @@ -41,4 +41,4 @@ public enum GenerateContentError: Error { /// - Important: The API is only available in /// [specific regions](https://ai.google.dev/available_regions#available_regions). case unsupportedUserLocation -} +} \ No newline at end of file diff --git a/Sources/GoogleAI/GenerateContentRequest.swift b/Sources/GoogleAI/GenerateContentRequest.swift index b3bd98c..49ba5e8 100644 --- a/Sources/GoogleAI/GenerateContentRequest.swift +++ b/Sources/GoogleAI/GenerateContentRequest.swift @@ -14,7 +14,7 @@ import Foundation -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) struct GenerateContentRequest { /// Model name. let model: String @@ -28,7 +28,7 @@ struct GenerateContentRequest { let options: RequestOptions } -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) extension GenerateContentRequest: Encodable { enum CodingKeys: String, CodingKey { case model @@ -53,4 +53,4 @@ extension GenerateContentRequest: GenerativeAIRequest { return URL(string: "\(modelURL):generateContent")! } } -} +} \ No newline at end of file diff --git a/Sources/GoogleAI/GenerateContentResponse.swift b/Sources/GoogleAI/GenerateContentResponse.swift index afbbb53..27a3e17 100644 --- a/Sources/GoogleAI/GenerateContentResponse.swift +++ b/Sources/GoogleAI/GenerateContentResponse.swift @@ -82,7 +82,7 @@ public struct GenerateContentResponse { /// A struct representing a possible reply to a content generation prompt. Each content generation /// prompt may produce multiple candidate responses. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) public struct CandidateResponse { /// The response's content. public let content: ModelContent @@ -108,14 +108,14 @@ public struct CandidateResponse { } /// A collection of source attributions for a piece of content. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) public struct CitationMetadata { /// A list of individual cited sources and the parts of the content to which they apply. public let citationSources: [Citation] } /// A struct describing a source attribution. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) public struct Citation { /// The inclusive beginning of a sequence in a model response that derives from a cited source. public let startIndex: Int @@ -131,7 +131,7 @@ public struct Citation { } /// A value enumerating possible reasons for a model to terminate a content generation request. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) public enum FinishReason: String { case unknown = "FINISH_REASON_UNKNOWN" @@ -156,7 +156,7 @@ public enum FinishReason: String { } /// A metadata struct containing any feedback the model had on the prompt it was provided. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) public struct PromptFeedback { /// A type describing possible reasons to block a prompt. public enum BlockReason: String { @@ -239,7 +239,7 @@ extension GenerateContentResponse.UsageMetadata: Decodable { } } -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) extension CandidateResponse: Decodable { enum CodingKeys: CodingKey { case content @@ -286,10 +286,10 @@ extension CandidateResponse: Decodable { } } -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) extension CitationMetadata: Decodable {} -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) extension Citation: Decodable { enum CodingKeys: CodingKey { case startIndex @@ -342,7 +342,7 @@ extension PromptFeedback.BlockReason: Decodable { } } -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) extension PromptFeedback: Decodable { enum CodingKeys: CodingKey { case blockReason @@ -364,4 +364,4 @@ extension PromptFeedback: Decodable { safetyRatings = [] } } -} +} \ No newline at end of file diff --git a/Sources/GoogleAI/GenerationConfig.swift b/Sources/GoogleAI/GenerationConfig.swift index 137a74f..f173b87 100644 --- a/Sources/GoogleAI/GenerationConfig.swift +++ b/Sources/GoogleAI/GenerationConfig.swift @@ -16,7 +16,7 @@ import Foundation /// A struct defining model parameters to be used when sending generative AI /// requests to the backend model. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) public struct GenerationConfig { /// A parameter controlling the degree of randomness in token selection. A /// temperature of zero is deterministic, always choosing the @@ -106,5 +106,5 @@ public struct GenerationConfig { // MARK: - Codable Conformances -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) -extension GenerationConfig: Encodable {} +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) +extension GenerationConfig: Encodable {} \ No newline at end of file diff --git a/Sources/GoogleAI/GenerativeAIRequest.swift b/Sources/GoogleAI/GenerativeAIRequest.swift index 1faa2c8..dd9693c 100644 --- a/Sources/GoogleAI/GenerativeAIRequest.swift +++ b/Sources/GoogleAI/GenerativeAIRequest.swift @@ -14,7 +14,7 @@ import Foundation -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) protocol GenerativeAIRequest: Encodable { associatedtype Response: Decodable @@ -24,7 +24,7 @@ protocol GenerativeAIRequest: Encodable { } /// Configuration parameters for sending requests to the backend. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) public struct RequestOptions { /// The request’s timeout interval in seconds. let timeout: TimeInterval @@ -41,4 +41,4 @@ public struct RequestOptions { self.timeout = timeout self.apiVersion = apiVersion } -} +} \ No newline at end of file diff --git a/Sources/GoogleAI/GenerativeAIService.swift b/Sources/GoogleAI/GenerativeAIService.swift index 3e8cc88..adafb47 100644 --- a/Sources/GoogleAI/GenerativeAIService.swift +++ b/Sources/GoogleAI/GenerativeAIService.swift @@ -52,7 +52,7 @@ struct GenerativeAIService { return try parseResponse(T.Response.self, from: data) } - @available(macOS 12.0, *) + @available(macOS 12.0, watchOS 8.0, *) func loadRequestStream(request: T) -> AsyncThrowingStream { return AsyncThrowingStream { continuation in @@ -161,6 +161,7 @@ struct GenerativeAIService { return urlRequest } + @available(watchOS 7.0, *) private func httpResponse(urlResponse: URLResponse) throws -> HTTPURLResponse { // Verify the status code is 200 guard let response = urlResponse as? HTTPURLResponse else { @@ -209,6 +210,7 @@ struct GenerativeAIService { } } + @available(watchOS 7.0, *) private func parseResponse(_ type: T.Type, from data: Data) throws -> T { do { return try JSONDecoder().decode(type, from: data) @@ -222,6 +224,7 @@ struct GenerativeAIService { } #if DEBUG + @available(watchOS 7.0, *) private func cURLCommand(from request: URLRequest) -> String { var returnValue = "curl " if let allHeaders = request.allHTTPHeaderFields { @@ -251,4 +254,4 @@ struct GenerativeAIService { """) } #endif // DEBUG -} +} \ No newline at end of file diff --git a/Sources/GoogleAI/GenerativeAISwift.swift b/Sources/GoogleAI/GenerativeAISwift.swift index 9de722d..52d0557 100644 --- a/Sources/GoogleAI/GenerativeAISwift.swift +++ b/Sources/GoogleAI/GenerativeAISwift.swift @@ -18,10 +18,10 @@ import Foundation #endif /// Constants associated with the GenerativeAISwift SDK. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) public enum GenerativeAISwift { /// String value of the SDK version public static let version = "0.5.4" /// The Google AI backend endpoint URL. static let baseURL = "https://generativelanguage.googleapis.com" -} +} \ No newline at end of file diff --git a/Sources/GoogleAI/GenerativeModel.swift b/Sources/GoogleAI/GenerativeModel.swift index ac8cf30..d4ebdf5 100644 --- a/Sources/GoogleAI/GenerativeModel.swift +++ b/Sources/GoogleAI/GenerativeModel.swift @@ -220,7 +220,7 @@ public final class GenerativeModel { /// for conforming types). /// - Returns: A stream wrapping content generated by the model or a ``GenerateContentError`` /// error if an error occurred. - @available(macOS 12.0, *) + @available(macOS 12.0, watchOS 8.0, *) public func generateContentStream(_ parts: any ThrowingPartsRepresentable...) -> AsyncThrowingStream { return try generateContentStream([ModelContent(parts: parts)]) @@ -231,7 +231,7 @@ public final class GenerativeModel { /// - Parameter content: The input(s) given to the model as a prompt. /// - Returns: A stream wrapping content generated by the model or a ``GenerateContentError`` /// error if an error occurred. - @available(macOS 12.0, *) + @available(macOS 12.0, watchOS 8.0, *) public func generateContentStream(_ content: @autoclosure () throws -> [ModelContent]) -> AsyncThrowingStream { let evaluatedContent: [ModelContent] @@ -370,7 +370,7 @@ public final class GenerativeModel { } /// An error thrown in `GenerativeModel.countTokens(_:)`. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) public enum CountTokensError: Error { case internalError(underlying: Error) -} +} \ No newline at end of file diff --git a/Sources/GoogleAI/JSONValue.swift b/Sources/GoogleAI/JSONValue.swift index 5ce52cd..df87be7 100644 --- a/Sources/GoogleAI/JSONValue.swift +++ b/Sources/GoogleAI/JSONValue.swift @@ -93,4 +93,4 @@ extension JSONValue: Encodable { } } -extension JSONValue: Equatable {} +extension JSONValue: Equatable {} \ No newline at end of file diff --git a/Sources/GoogleAI/Logging.swift b/Sources/GoogleAI/Logging.swift index 73dda23..16ffe24 100644 --- a/Sources/GoogleAI/Logging.swift +++ b/Sources/GoogleAI/Logging.swift @@ -53,4 +53,4 @@ struct Logging { return Logger(.disabled) } }() -} +} \ No newline at end of file diff --git a/Sources/GoogleAI/ModelContent.swift b/Sources/GoogleAI/ModelContent.swift index 0106927..81471d9 100644 --- a/Sources/GoogleAI/ModelContent.swift +++ b/Sources/GoogleAI/ModelContent.swift @@ -17,7 +17,7 @@ import Foundation /// A type describing data in media formats interpretable by an AI model. Each generative AI /// request or response contains an `Array` of ``ModelContent``s, and each ``ModelContent`` value /// may comprise multiple heterogeneous ``ModelContent/Part``s. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) public struct ModelContent: Equatable { /// A discrete piece of data in a media format intepretable by an AI model. Within a single value /// of ``Part``, different data types may not mix. @@ -118,10 +118,10 @@ public struct ModelContent: Equatable { // MARK: Codable Conformances -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) extension ModelContent: Codable {} -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) extension ModelContent.Part: Codable { enum CodingKeys: String, CodingKey { case text @@ -188,4 +188,4 @@ extension ModelContent.Part: Codable { )) } } -} +} \ No newline at end of file diff --git a/Sources/GoogleAI/PartsRepresentable+Image.swift b/Sources/GoogleAI/PartsRepresentable+Image.swift index bc37cbd..1d7a377 100644 --- a/Sources/GoogleAI/PartsRepresentable+Image.swift +++ b/Sources/GoogleAI/PartsRepresentable+Image.swift @@ -38,7 +38,7 @@ public enum ImageConversionError: Error { #if canImport(UIKit) /// Enables images to be representable as ``ThrowingPartsRepresentable``. - @available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) + @available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) extension UIImage: ThrowingPartsRepresentable { public func tryPartsValue() throws -> [ModelContent.Part] { guard let data = jpegData(compressionQuality: imageCompressionQuality) else { @@ -50,7 +50,7 @@ public enum ImageConversionError: Error { #elseif canImport(AppKit) /// Enables images to be representable as ``ThrowingPartsRepresentable``. - @available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) + @available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) extension NSImage: ThrowingPartsRepresentable { public func tryPartsValue() throws -> [ModelContent.Part] { guard let cgImage = cgImage(forProposedRect: nil, context: nil, hints: nil) else { @@ -67,7 +67,7 @@ public enum ImageConversionError: Error { #endif /// Enables `CGImages` to be representable as model content. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) extension CGImage: ThrowingPartsRepresentable { public func tryPartsValue() throws -> [ModelContent.Part] { let output = NSMutableData() @@ -88,7 +88,8 @@ extension CGImage: ThrowingPartsRepresentable { } /// Enables `CIImages` to be representable as model content. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +#if !os(watchOS) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) extension CIImage: ThrowingPartsRepresentable { public func tryPartsValue() throws -> [ModelContent.Part] { let context = CIContext() @@ -105,3 +106,4 @@ extension CIImage: ThrowingPartsRepresentable { throw ImageConversionError.couldNotConvertToJPEG(self) } } +#endif diff --git a/Sources/GoogleAI/PartsRepresentable.swift b/Sources/GoogleAI/PartsRepresentable.swift index a4272ad..5251b47 100644 --- a/Sources/GoogleAI/PartsRepresentable.swift +++ b/Sources/GoogleAI/PartsRepresentable.swift @@ -16,7 +16,7 @@ import Foundation /// A protocol describing any data that could be serialized to model-interpretable input data, /// where the serialization process might fail with an error. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) public protocol ThrowingPartsRepresentable { func tryPartsValue() throws -> [ModelContent.Part] } @@ -24,12 +24,12 @@ public protocol ThrowingPartsRepresentable { /// A protocol describing any data that could be serialized to model-interpretable input data, /// where the serialization process cannot fail with an error. For a failable conversion, see /// ``ThrowingPartsRepresentable`` -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) public protocol PartsRepresentable: ThrowingPartsRepresentable { var partsValue: [ModelContent.Part] { get } } -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) public extension PartsRepresentable { func tryPartsValue() throws -> [ModelContent.Part] { return partsValue @@ -37,7 +37,7 @@ public extension PartsRepresentable { } /// Enables a ``ModelContent.Part`` to be passed in as ``ThrowingPartsRepresentable``. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) extension ModelContent.Part: ThrowingPartsRepresentable { public typealias ErrorType = Never public func tryPartsValue() throws -> [ModelContent.Part] { @@ -47,7 +47,7 @@ extension ModelContent.Part: ThrowingPartsRepresentable { /// Enable an `Array` of ``ThrowingPartsRepresentable`` values to be passed in as a single /// ``ThrowingPartsRepresentable``. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) extension [ThrowingPartsRepresentable]: ThrowingPartsRepresentable { public func tryPartsValue() throws -> [ModelContent.Part] { return try compactMap { element in @@ -58,9 +58,9 @@ extension [ThrowingPartsRepresentable]: ThrowingPartsRepresentable { } /// Enables a `String` to be passed in as ``ThrowingPartsRepresentable``. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) extension String: PartsRepresentable { public var partsValue: [ModelContent.Part] { return [.text(self)] } -} +} \ No newline at end of file diff --git a/Sources/GoogleAI/Safety.swift b/Sources/GoogleAI/Safety.swift index 0deaf3e..d8b5d7c 100644 --- a/Sources/GoogleAI/Safety.swift +++ b/Sources/GoogleAI/Safety.swift @@ -17,7 +17,7 @@ import Foundation /// A type defining potentially harmful media categories and their model-assigned ratings. A value /// of this type may be assigned to a category for every model-generated response, not just /// responses that exceed a certain threshold. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) public struct SafetyRating: Equatable, Hashable { /// The category describing the potential harm a piece of content may pose. See /// ``SafetySetting/HarmCategory`` for a list of possible values. @@ -61,7 +61,7 @@ public struct SafetyRating: Equatable, Hashable { } /// Safety feedback for an entire request. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) public struct SafetyFeedback { /// Safety rating evaluated from content. public let rating: SafetyRating @@ -78,7 +78,7 @@ public struct SafetyFeedback { /// A type used to specify a threshold for harmful content, beyond which the model will return a /// fallback response instead of generated content. -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) public struct SafetySetting { /// A type describing safety attributes, which include harmful categories and topics that can /// be considered sensitive. @@ -158,10 +158,10 @@ extension SafetyRating.HarmProbability: Codable { } } -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) extension SafetyRating: Decodable {} -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) extension SafetyFeedback: Decodable {} @available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) @@ -194,5 +194,5 @@ extension SafetySetting.BlockThreshold: Codable { } } -@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *) -extension SafetySetting: Codable {} +@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *) +extension SafetySetting: Codable {} \ No newline at end of file