Skip to content

Commit 76fcc90

Browse files
authored
[Vertex AI] Add Sendable conformance to types (#13560)
1 parent ade83e9 commit 76fcc90

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

FirebaseVertexAI/Sources/FunctionCalling.swift

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

1717
/// A predicted function call returned from the model.
18-
public struct FunctionCall: Equatable {
18+
public struct FunctionCall: Equatable, Sendable {
1919
/// The name of the function to call.
2020
public let name: String
2121

@@ -131,7 +131,7 @@ public struct ToolConfig {
131131
/// Contains a string representing the `FunctionDeclaration.name` and a structured JSON object
132132
/// containing any output from the function is used as context to the model. This should contain the
133133
/// result of a ``FunctionCall`` made based on model prediction.
134-
public struct FunctionResponse: Equatable {
134+
public struct FunctionResponse: Equatable, Sendable {
135135
/// The name of the function that was called.
136136
let name: String
137137

FirebaseVertexAI/Sources/GenerateContentResponse.swift

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

1717
/// The model's response to a generate content request.
1818
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
19-
public struct GenerateContentResponse {
19+
public struct GenerateContentResponse: Sendable {
2020
/// Token usage metadata for processing the generate content request.
21-
public struct UsageMetadata {
21+
public struct UsageMetadata: Sendable {
2222
/// The number of tokens in the request prompt.
2323
public let promptTokenCount: Int
2424

@@ -85,7 +85,7 @@ public struct GenerateContentResponse {
8585
/// A struct representing a possible reply to a content generation prompt. Each content generation
8686
/// prompt may produce multiple candidate responses.
8787
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
88-
public struct CandidateResponse {
88+
public struct CandidateResponse: Sendable {
8989
/// The response's content.
9090
public let content: ModelContent
9191

@@ -111,14 +111,14 @@ public struct CandidateResponse {
111111

112112
/// A collection of source attributions for a piece of content.
113113
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
114-
public struct CitationMetadata {
114+
public struct CitationMetadata: Sendable {
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.
120120
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
121-
public struct Citation {
121+
public struct Citation: Sendable {
122122
/// The inclusive beginning of a sequence in a model response that derives from a cited source.
123123
public let startIndex: Int
124124

@@ -137,7 +137,7 @@ public struct Citation {
137137

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

143143
case unspecified = "FINISH_REASON_UNSPECIFIED"
@@ -162,9 +162,9 @@ public enum FinishReason: String {
162162

163163
/// A metadata struct containing any feedback the model had on the prompt it was provided.
164164
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
165-
public struct PromptFeedback {
165+
public struct PromptFeedback: Sendable {
166166
/// A type describing possible reasons to block a prompt.
167-
public enum BlockReason: String {
167+
public enum BlockReason: String, Sendable {
168168
/// The block reason is unknown.
169169
case unknown = "UNKNOWN"
170170

FirebaseVertexAI/Sources/JSONValue.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public typealias JSONObject = [String: JSONValue]
2424
///
2525
/// This may be decoded from, or encoded to, a
2626
/// [`google.protobuf.Value`](https://protobuf.dev/reference/protobuf/google.protobuf/#value).
27-
public enum JSONValue {
27+
public enum JSONValue: Sendable {
2828
/// A `null` value.
2929
case null
3030

FirebaseVertexAI/Sources/ModelContent.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ import Foundation
1818
/// request or response contains an `Array` of ``ModelContent``s, and each ``ModelContent`` value
1919
/// may comprise multiple heterogeneous ``ModelContent/Part``s.
2020
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
21-
public struct ModelContent: Equatable {
21+
public struct ModelContent: Equatable, Sendable {
2222
/// A discrete piece of data in a media format interpretable by an AI model. Within a single value
2323
/// of ``Part``, different data types may not mix.
24-
public enum Part: Equatable {
24+
public enum Part: Equatable, Sendable {
2525
/// Text value.
2626
case text(String)
2727

FirebaseVertexAI/Sources/Safety.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Foundation
1818
/// of this type may be assigned to a category for every model-generated response, not just
1919
/// responses that exceed a certain threshold.
2020
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
21-
public struct SafetyRating: Equatable, Hashable {
21+
public struct SafetyRating: Equatable, Hashable, Sendable {
2222
/// The category describing the potential harm a piece of content may pose. See
2323
/// ``SafetySetting/HarmCategory`` for a list of possible values.
2424
public let category: SafetySetting.HarmCategory
@@ -37,7 +37,7 @@ public struct SafetyRating: Equatable, Hashable {
3737

3838
/// The probability that a given model output falls under a harmful content category. This does
3939
/// not indicate the severity of harm for a piece of content.
40-
public enum HarmProbability: String {
40+
public enum HarmProbability: String, Sendable {
4141
/// Unknown. A new server value that isn't recognized by the SDK.
4242
case unknown = "UNKNOWN"
4343

@@ -81,7 +81,7 @@ public struct SafetyFeedback {
8181
public struct SafetySetting {
8282
/// A type describing safety attributes, which include harmful categories and topics that can
8383
/// be considered sensitive.
84-
public enum HarmCategory: String {
84+
public enum HarmCategory: String, Sendable {
8585
/// Unknown. A new server value that isn't recognized by the SDK.
8686
case unknown = "HARM_CATEGORY_UNKNOWN"
8787

@@ -102,7 +102,7 @@ public struct SafetySetting {
102102
}
103103

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

0 commit comments

Comments
 (0)