Skip to content

Commit 61e5960

Browse files
committed
Re-ordered parameters to align with the Android SDK
1 parent 90857d6 commit 61e5960

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

FirebaseAI/Sources/Types/Internal/InternalPart.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,26 @@ struct FileData: Codable, Equatable, Sendable {
4444
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
4545
struct FunctionCall: Equatable, Sendable {
4646
let name: String
47-
let id: String?
4847
let args: JSONObject
48+
let id: String?
4949

50-
init(name: String, id: String?, args: JSONObject) {
50+
init(name: String, args: JSONObject, id: String?) {
5151
self.name = name
52-
self.id = id
5352
self.args = args
53+
self.id = id
5454
}
5555
}
5656

5757
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
5858
struct FunctionResponse: Codable, Equatable, Sendable {
5959
let name: String
60-
let id: String?
6160
let response: JSONObject
61+
let id: String?
6262

63-
init(name: String, id: String?, response: JSONObject) {
63+
init(name: String, response: JSONObject, id: String?) {
6464
self.name = name
65-
self.id = id
6665
self.response = response
66+
self.id = id
6767
}
6868
}
6969

FirebaseAI/Sources/Types/Public/Part.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ public struct FunctionCallPart: Part {
109109
/// The name of the function to call.
110110
public var name: String { functionCall.name }
111111

112+
/// The function parameters and values.
113+
public var args: JSONObject { functionCall.args }
114+
112115
/// The unique ID of the function call. If specified, this identifier should be included in the
113116
/// ``FunctionResponsePart``.
114117
public var id: String? { functionCall.id }
115118

116-
/// The function parameters and values.
117-
public var args: JSONObject { functionCall.args }
118-
119119
/// Constructs a new function call part.
120120
///
121121
/// > Note: A `FunctionCallPart` is typically received from the model, rather than created
@@ -125,7 +125,7 @@ public struct FunctionCallPart: Part {
125125
/// - name: The name of the function to call.
126126
/// - args: The function parameters and values.
127127
public init(name: String, args: JSONObject) {
128-
self.init(FunctionCall(name: name, id: nil, args: args))
128+
self.init(FunctionCall(name: name, args: args, id: nil))
129129
}
130130

131131
init(_ functionCall: FunctionCall) {
@@ -152,11 +152,11 @@ public struct FunctionResponsePart: Part {
152152
///
153153
/// - Parameters:
154154
/// - name: The name of the function that was called.
155+
/// - response: The function's response.
155156
/// - id: The unique ID of the function call, if specified, that this response corresponds with;
156157
/// see ``FunctionCallPart/id`` for more details.
157-
/// - response: The function's response.
158-
public init(name: String, id: String? = nil, response: JSONObject) {
159-
self.init(FunctionResponse(name: name, id: id, response: response))
158+
public init(name: String, response: JSONObject, id: String? = nil) {
159+
self.init(FunctionResponse(name: name, response: response, id: id))
160160
}
161161

162162
init(_ functionResponse: FunctionResponse) {

FirebaseAI/Tests/Unit/Snippets/FunctionCallingSnippets.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ final class FunctionCallingSnippets: XCTestCase {
9292

9393
functionResponses.append(FunctionResponsePart(
9494
name: functionCall.name,
95-
id: functionCall.id,
96-
response: fetchWeather(city: city, state: state, date: date)
95+
response: fetchWeather(city: city, state: state, date: date),
96+
id: functionCall.id
9797
))
9898
}
9999
// TODO(developer): Handle other potential function calls, if any.

0 commit comments

Comments
 (0)