Skip to content

Commit 102ae79

Browse files
authored
[Vertex AI] Add support for compiling on watchOS (#13215)
1 parent 5362cc2 commit 102ae79

28 files changed

+182
-149
lines changed

.github/workflows/vertexai.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
spm-unit:
1919
strategy:
2020
matrix:
21-
target: [iOS, macOS, catalyst, tvOS, visionOS]
21+
target: [iOS, macOS, catalyst, tvOS, visionOS, watchOS]
2222
os: [macos-14]
2323
include:
2424
- os: macos-14

FirebaseVertexAI/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 10.29.0
2+
- [feature] Added community support for watchOS. (#13215)
3+
14
# 10.28.0
25
- [changed] Removed uses of the `gemini-1.5-flash-preview-0514` model in docs
36
and samples. Developers should now use the auto-updated versions,

FirebaseVertexAI/Sources/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, tvOS 15.0, *)
19+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
2020
public class Chat {
2121
private let model: GenerativeModel
2222

FirebaseVertexAI/Sources/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, tvOS 15.0, *)
17+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
1818
struct CountTokensRequest {
1919
let model: String
2020
let contents: [ModelContent]
2121
let options: RequestOptions
2222
}
2323

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

@@ -31,7 +31,7 @@ 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, tvOS 15.0, *)
34+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.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
@@ -45,14 +45,14 @@ public struct CountTokensResponse {
4545

4646
// MARK: - Codable Conformances
4747

48-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, *)
48+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
4949
extension CountTokensRequest: Encodable {
5050
enum CodingKeys: CodingKey {
5151
case contents
5252
}
5353
}
5454

55-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, *)
55+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
5656
extension CountTokensResponse: Decodable {
5757
enum CodingKeys: CodingKey {
5858
case totalTokens

FirebaseVertexAI/Sources/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, tvOS 15.0, *)
18+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.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)

FirebaseVertexAI/Sources/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, tvOS 15.0, *)
17+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.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, tvOS 15.0, *)
31+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
3232
extension GenerateContentRequest: Encodable {
3333
enum CodingKeys: String, CodingKey {
3434
case contents
@@ -40,7 +40,7 @@ extension GenerateContentRequest: Encodable {
4040
}
4141
}
4242

43-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, *)
43+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
4444
extension GenerateContentRequest: GenerativeAIRequest {
4545
typealias Response = GenerateContentResponse
4646

FirebaseVertexAI/Sources/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, tvOS 15.0, *)
18+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
1919
public struct GenerateContentResponse {
2020
/// Token usage metadata for processing the generate content request.
2121
public struct UsageMetadata {
@@ -84,7 +84,7 @@ public struct GenerateContentResponse {
8484

8585
/// A struct representing a possible reply to a content generation prompt. Each content generation
8686
/// prompt may produce multiple candidate responses.
87-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, *)
87+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
8888
public struct CandidateResponse {
8989
/// The response's content.
9090
public let content: ModelContent
@@ -110,14 +110,14 @@ public struct CandidateResponse {
110110
}
111111

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

119119
/// A struct describing a source attribution.
120-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, *)
120+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
121121
public struct Citation {
122122
/// The inclusive beginning of a sequence in a model response that derives from a cited source.
123123
public let startIndex: Int
@@ -133,7 +133,7 @@ public struct Citation {
133133
}
134134

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

@@ -158,7 +158,7 @@ public enum FinishReason: String {
158158
}
159159

160160
/// A metadata struct containing any feedback the model had on the prompt it was provided.
161-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, *)
161+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
162162
public struct PromptFeedback {
163163
/// A type describing possible reasons to block a prompt.
164164
public enum BlockReason: String {
@@ -190,7 +190,7 @@ public struct PromptFeedback {
190190

191191
// MARK: - Codable Conformances
192192

193-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, *)
193+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
194194
extension GenerateContentResponse: Decodable {
195195
enum CodingKeys: CodingKey {
196196
case candidates
@@ -224,7 +224,7 @@ extension GenerateContentResponse: Decodable {
224224
}
225225
}
226226

227-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, *)
227+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
228228
extension GenerateContentResponse.UsageMetadata: Decodable {
229229
enum CodingKeys: CodingKey {
230230
case promptTokenCount
@@ -241,7 +241,7 @@ extension GenerateContentResponse.UsageMetadata: Decodable {
241241
}
242242
}
243243

244-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, *)
244+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
245245
extension CandidateResponse: Decodable {
246246
enum CodingKeys: CodingKey {
247247
case content
@@ -290,14 +290,14 @@ extension CandidateResponse: Decodable {
290290
}
291291
}
292292

293-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, *)
293+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
294294
extension CitationMetadata: Decodable {
295295
enum CodingKeys: String, CodingKey {
296296
case citationSources = "citations"
297297
}
298298
}
299299

300-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, *)
300+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
301301
extension Citation: Decodable {
302302
enum CodingKeys: CodingKey {
303303
case startIndex
@@ -315,7 +315,7 @@ extension Citation: Decodable {
315315
}
316316
}
317317

318-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, *)
318+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
319319
extension FinishReason: Decodable {
320320
public init(from decoder: Decoder) throws {
321321
let value = try decoder.singleValueContainer().decode(String.self)
@@ -330,7 +330,7 @@ extension FinishReason: Decodable {
330330
}
331331
}
332332

333-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, *)
333+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
334334
extension PromptFeedback.BlockReason: Decodable {
335335
public init(from decoder: Decoder) throws {
336336
let value = try decoder.singleValueContainer().decode(String.self)
@@ -345,7 +345,7 @@ extension PromptFeedback.BlockReason: Decodable {
345345
}
346346
}
347347

348-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, *)
348+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
349349
extension PromptFeedback: Decodable {
350350
enum CodingKeys: CodingKey {
351351
case blockReason

FirebaseVertexAI/Sources/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, tvOS 15.0, *)
19+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.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
@@ -95,5 +95,5 @@ public struct GenerationConfig {
9595

9696
// MARK: - Codable Conformances
9797

98-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, *)
98+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
9999
extension GenerationConfig: Encodable {}

FirebaseVertexAI/Sources/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, tvOS 15.0, *)
17+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.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, tvOS 15.0, *)
27+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
2828
public struct RequestOptions {
2929
/// The request’s timeout interval in seconds; if not specified uses the default value for a
3030
/// `URLRequest`.

FirebaseVertexAI/Sources/GenerativeAIService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import FirebaseAuthInterop
1717
import FirebaseCore
1818
import Foundation
1919

20-
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, *)
20+
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
2121
struct GenerativeAIService {
2222
/// The language of the SDK in the format `gl-<language>/<version>`.
2323
static let languageTag = "gl-swift/5"

0 commit comments

Comments
 (0)