Skip to content

Commit a786f63

Browse files
committed
Add support to watchOS from 7.0 (or at least fixing build errors)
1 parent 5478400 commit a786f63

15 files changed

+55
-55
lines changed

Sources/GoogleAI/Chat.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Foundation
1616

1717
/// An object that represents a back-and-forth chat with a model, capturing the history and saving
1818
/// the context in memory between each message sent.
19-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
19+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
2020
public class Chat {
2121
private let model: GenerativeModel
2222

Sources/GoogleAI/CountTokensRequest.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414

1515
import Foundation
1616

17-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
17+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
1818
struct CountTokensRequest {
1919
let model: String
2020
let generateContentRequest: GenerateContentRequest
2121
let options: RequestOptions
2222
}
2323

24-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
24+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
2525
extension CountTokensRequest: GenerativeAIRequest {
2626
typealias Response = CountTokensResponse
2727

@@ -31,20 +31,20 @@ extension CountTokensRequest: GenerativeAIRequest {
3131
}
3232

3333
/// The model's response to a count tokens request.
34-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
34+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
3535
public struct CountTokensResponse {
3636
/// The total number of tokens in the input given to the model as a prompt.
3737
public let totalTokens: Int
3838
}
3939

4040
// MARK: - Codable Conformances
4141

42-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
42+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
4343
extension CountTokensRequest: Encodable {
4444
enum CodingKeys: CodingKey {
4545
case generateContentRequest
4646
}
4747
}
4848

49-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
49+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
5050
extension CountTokensResponse: Decodable {}

Sources/GoogleAI/GenerateContentError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import Foundation
1616

1717
/// Errors that occur when generating content from a model.
18-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
18+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
1919
public enum GenerateContentError: Error {
2020
/// An error occurred when constructing the prompt. Examine the related error for details.
2121
case promptImageContentError(underlying: ImageConversionError)

Sources/GoogleAI/GenerateContentRequest.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import Foundation
1616

17-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
17+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
1818
struct GenerateContentRequest {
1919
/// Model name.
2020
let model: String
@@ -28,7 +28,7 @@ struct GenerateContentRequest {
2828
let options: RequestOptions
2929
}
3030

31-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
31+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
3232
extension GenerateContentRequest: Encodable {
3333
enum CodingKeys: String, CodingKey {
3434
case model
@@ -41,7 +41,7 @@ extension GenerateContentRequest: Encodable {
4141
}
4242
}
4343

44-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
44+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
4545
extension GenerateContentRequest: GenerativeAIRequest {
4646
typealias Response = GenerateContentResponse
4747

Sources/GoogleAI/GenerateContentResponse.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import Foundation
1616

1717
/// The model's response to a generate content request.
18-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
18+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
1919
public struct GenerateContentResponse {
2020
/// Token usage metadata for processing the generate content request.
2121
public struct UsageMetadata {
@@ -82,7 +82,7 @@ public struct GenerateContentResponse {
8282

8383
/// A struct representing a possible reply to a content generation prompt. Each content generation
8484
/// prompt may produce multiple candidate responses.
85-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
85+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
8686
public struct CandidateResponse {
8787
/// The response's content.
8888
public let content: ModelContent
@@ -108,14 +108,14 @@ public struct CandidateResponse {
108108
}
109109

110110
/// A collection of source attributions for a piece of content.
111-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
111+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
112112
public struct CitationMetadata {
113113
/// A list of individual cited sources and the parts of the content to which they apply.
114114
public let citationSources: [Citation]
115115
}
116116

117117
/// A struct describing a source attribution.
118-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
118+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
119119
public struct Citation {
120120
/// The inclusive beginning of a sequence in a model response that derives from a cited source.
121121
public let startIndex: Int
@@ -131,7 +131,7 @@ public struct Citation {
131131
}
132132

133133
/// A value enumerating possible reasons for a model to terminate a content generation request.
134-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
134+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
135135
public enum FinishReason: String {
136136
case unknown = "FINISH_REASON_UNKNOWN"
137137

@@ -156,7 +156,7 @@ public enum FinishReason: String {
156156
}
157157

158158
/// A metadata struct containing any feedback the model had on the prompt it was provided.
159-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
159+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
160160
public struct PromptFeedback {
161161
/// A type describing possible reasons to block a prompt.
162162
public enum BlockReason: String {
@@ -188,7 +188,7 @@ public struct PromptFeedback {
188188

189189
// MARK: - Codable Conformances
190190

191-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
191+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
192192
extension GenerateContentResponse: Decodable {
193193
enum CodingKeys: CodingKey {
194194
case candidates
@@ -222,7 +222,7 @@ extension GenerateContentResponse: Decodable {
222222
}
223223
}
224224

225-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
225+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
226226
extension GenerateContentResponse.UsageMetadata: Decodable {
227227
enum CodingKeys: CodingKey {
228228
case promptTokenCount
@@ -239,7 +239,7 @@ extension GenerateContentResponse.UsageMetadata: Decodable {
239239
}
240240
}
241241

242-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
242+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
243243
extension CandidateResponse: Decodable {
244244
enum CodingKeys: CodingKey {
245245
case content
@@ -286,10 +286,10 @@ extension CandidateResponse: Decodable {
286286
}
287287
}
288288

289-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
289+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
290290
extension CitationMetadata: Decodable {}
291291

292-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
292+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
293293
extension Citation: Decodable {
294294
enum CodingKeys: CodingKey {
295295
case startIndex
@@ -312,7 +312,7 @@ extension Citation: Decodable {
312312
}
313313
}
314314

315-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
315+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
316316
extension FinishReason: Decodable {
317317
public init(from decoder: Decoder) throws {
318318
let value = try decoder.singleValueContainer().decode(String.self)
@@ -327,7 +327,7 @@ extension FinishReason: Decodable {
327327
}
328328
}
329329

330-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
330+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
331331
extension PromptFeedback.BlockReason: Decodable {
332332
public init(from decoder: Decoder) throws {
333333
let value = try decoder.singleValueContainer().decode(String.self)
@@ -342,7 +342,7 @@ extension PromptFeedback.BlockReason: Decodable {
342342
}
343343
}
344344

345-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
345+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
346346
extension PromptFeedback: Decodable {
347347
enum CodingKeys: CodingKey {
348348
case blockReason

Sources/GoogleAI/GenerationConfig.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Foundation
1616

1717
/// A struct defining model parameters to be used when sending generative AI
1818
/// requests to the backend model.
19-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
19+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
2020
public struct GenerationConfig {
2121
/// A parameter controlling the degree of randomness in token selection. A
2222
/// temperature of zero is deterministic, always choosing the
@@ -106,5 +106,5 @@ public struct GenerationConfig {
106106

107107
// MARK: - Codable Conformances
108108

109-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
109+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
110110
extension GenerationConfig: Encodable {}

Sources/GoogleAI/GenerativeAIRequest.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import Foundation
1616

17-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
17+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
1818
protocol GenerativeAIRequest: Encodable {
1919
associatedtype Response: Decodable
2020

@@ -24,7 +24,7 @@ protocol GenerativeAIRequest: Encodable {
2424
}
2525

2626
/// Configuration parameters for sending requests to the backend.
27-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
27+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
2828
public struct RequestOptions {
2929
/// The request’s timeout interval in seconds.
3030
let timeout: TimeInterval

Sources/GoogleAI/GenerativeAIService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import Foundation
1616

17-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
17+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
1818
struct GenerativeAIService {
1919
/// Gives permission to talk to the backend.
2020
private let apiKey: String

Sources/GoogleAI/GenerativeAISwift.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Foundation
1818
#endif
1919

2020
/// Constants associated with the GenerativeAISwift SDK.
21-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
21+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
2222
public enum GenerativeAISwift {
2323
/// String value of the SDK version
2424
public static let version = "0.5.4"

Sources/GoogleAI/GenerativeModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Foundation
1616

1717
/// A type that represents a remote multimodal model (like Gemini), with the ability to generate
1818
/// content based on various input types.
19-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
19+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
2020
public final class GenerativeModel {
2121
// The prefix for a model resource in the Gemini API.
2222
private static let modelResourcePrefix = "models/"
@@ -370,7 +370,7 @@ public final class GenerativeModel {
370370
}
371371

372372
/// An error thrown in `GenerativeModel.countTokens(_:)`.
373-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
373+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
374374
public enum CountTokensError: Error {
375375
case internalError(underlying: Error)
376376
}

Sources/GoogleAI/Logging.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import Foundation
1616
import OSLog
1717

18-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
18+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
1919
struct Logging {
2020
/// Subsystem that should be used for all Loggers.
2121
static let subsystem = "com.google.generative-ai"

Sources/GoogleAI/ModelContent.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Foundation
1717
/// A type describing data in media formats interpretable by an AI model. Each generative AI
1818
/// request or response contains an `Array` of ``ModelContent``s, and each ``ModelContent`` value
1919
/// may comprise multiple heterogeneous ``ModelContent/Part``s.
20-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
20+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
2121
public struct ModelContent: Equatable {
2222
/// A discrete piece of data in a media format intepretable by an AI model. Within a single value
2323
/// of ``Part``, different data types may not mix.
@@ -118,10 +118,10 @@ public struct ModelContent: Equatable {
118118

119119
// MARK: Codable Conformances
120120

121-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
121+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
122122
extension ModelContent: Codable {}
123123

124-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
124+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
125125
extension ModelContent.Part: Codable {
126126
enum CodingKeys: String, CodingKey {
127127
case text

Sources/GoogleAI/PartsRepresentable+Image.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public enum ImageConversionError: Error {
3838

3939
#if canImport(UIKit)
4040
/// Enables images to be representable as ``ThrowingPartsRepresentable``.
41-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
41+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
4242
extension UIImage: ThrowingPartsRepresentable {
4343
public func tryPartsValue() throws -> [ModelContent.Part] {
4444
guard let data = jpegData(compressionQuality: imageCompressionQuality) else {
@@ -50,7 +50,7 @@ public enum ImageConversionError: Error {
5050

5151
#elseif canImport(AppKit)
5252
/// Enables images to be representable as ``ThrowingPartsRepresentable``.
53-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
53+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
5454
extension NSImage: ThrowingPartsRepresentable {
5555
public func tryPartsValue() throws -> [ModelContent.Part] {
5656
guard let cgImage = cgImage(forProposedRect: nil, context: nil, hints: nil) else {
@@ -67,7 +67,7 @@ public enum ImageConversionError: Error {
6767
#endif
6868

6969
/// Enables `CGImages` to be representable as model content.
70-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
70+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
7171
extension CGImage: ThrowingPartsRepresentable {
7272
public func tryPartsValue() throws -> [ModelContent.Part] {
7373
let output = NSMutableData()
@@ -88,7 +88,7 @@ extension CGImage: ThrowingPartsRepresentable {
8888
}
8989

9090
/// Enables `CIImages` to be representable as model content.
91-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
91+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
9292
extension CIImage: ThrowingPartsRepresentable {
9393
public func tryPartsValue() throws -> [ModelContent.Part] {
9494
let context = CIContext()

Sources/GoogleAI/PartsRepresentable.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,28 @@ import Foundation
1616

1717
/// A protocol describing any data that could be serialized to model-interpretable input data,
1818
/// where the serialization process might fail with an error.
19-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
19+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
2020
public protocol ThrowingPartsRepresentable {
2121
func tryPartsValue() throws -> [ModelContent.Part]
2222
}
2323

2424
/// A protocol describing any data that could be serialized to model-interpretable input data,
2525
/// where the serialization process cannot fail with an error. For a failable conversion, see
2626
/// ``ThrowingPartsRepresentable``
27-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
27+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
2828
public protocol PartsRepresentable: ThrowingPartsRepresentable {
2929
var partsValue: [ModelContent.Part] { get }
3030
}
3131

32-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
32+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
3333
public extension PartsRepresentable {
3434
func tryPartsValue() throws -> [ModelContent.Part] {
3535
return partsValue
3636
}
3737
}
3838

3939
/// Enables a ``ModelContent.Part`` to be passed in as ``ThrowingPartsRepresentable``.
40-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
40+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
4141
extension ModelContent.Part: ThrowingPartsRepresentable {
4242
public typealias ErrorType = Never
4343
public func tryPartsValue() throws -> [ModelContent.Part] {
@@ -47,7 +47,7 @@ extension ModelContent.Part: ThrowingPartsRepresentable {
4747

4848
/// Enable an `Array` of ``ThrowingPartsRepresentable`` values to be passed in as a single
4949
/// ``ThrowingPartsRepresentable``.
50-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
50+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
5151
extension [ThrowingPartsRepresentable]: ThrowingPartsRepresentable {
5252
public func tryPartsValue() throws -> [ModelContent.Part] {
5353
return try compactMap { element in
@@ -58,7 +58,7 @@ extension [ThrowingPartsRepresentable]: ThrowingPartsRepresentable {
5858
}
5959

6060
/// Enables a `String` to be passed in as ``ThrowingPartsRepresentable``.
61-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, *)
61+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, watchOS 7.0, *)
6262
extension String: PartsRepresentable {
6363
public var partsValue: [ModelContent.Part] {
6464
return [.text(self)]

0 commit comments

Comments
 (0)