From 2419ec396a15fa753ebf9d63abbfc888ae78ab1f Mon Sep 17 00:00:00 2001 From: Andrew Heard Date: Tue, 29 Oct 2024 12:23:43 -0400 Subject: [PATCH 1/3] [Vertex AI] Remove `format` for floating-point `Schema` types --- FirebaseVertexAI/Sources/Types/Public/Schema.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/FirebaseVertexAI/Sources/Types/Public/Schema.swift b/FirebaseVertexAI/Sources/Types/Public/Schema.swift index 93cf4f55127..68a842a269a 100644 --- a/FirebaseVertexAI/Sources/Types/Public/Schema.swift +++ b/FirebaseVertexAI/Sources/Types/Public/Schema.swift @@ -178,7 +178,8 @@ public class Schema { public static func float(description: String? = nil, nullable: Bool = false) -> Schema { return self.init( type: .number, - format: "float", + // TODO(andrewheard): Revert this change when the backend accepts "float" as a format again. + // format: "float", description: description, nullable: nullable ) @@ -202,7 +203,8 @@ public class Schema { public static func double(description: String? = nil, nullable: Bool = false) -> Schema { return self.init( type: .number, - format: "double", + // TODO(andrewheard): Revert this change when the backend accepts "double" as a format again. + // format: "double", description: description, nullable: nullable ) From 74d5bb78a2a375de6bee9b6e660f5ec1f998d9d9 Mon Sep 17 00:00:00 2001 From: Andrew Heard Date: Tue, 5 Nov 2024 16:01:59 -0500 Subject: [PATCH 2/3] Revert change for `float()`, edit `double()` docs --- .../Sources/Types/Public/Schema.swift | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/FirebaseVertexAI/Sources/Types/Public/Schema.swift b/FirebaseVertexAI/Sources/Types/Public/Schema.swift index 68a842a269a..a5fd2cdd0fb 100644 --- a/FirebaseVertexAI/Sources/Types/Public/Schema.swift +++ b/FirebaseVertexAI/Sources/Types/Public/Schema.swift @@ -178,22 +178,16 @@ public class Schema { public static func float(description: String? = nil, nullable: Bool = false) -> Schema { return self.init( type: .number, - // TODO(andrewheard): Revert this change when the backend accepts "float" as a format again. - // format: "float", + format: "float", description: description, nullable: nullable ) } - /// Returns a `Schema` representing a double-precision floating-point number. + /// Returns a `Schema` representing a floating-point number. /// - /// This schema instructs the model to produce data of type `"NUMBER"` with the `format` - /// `"double"`, which is suitable for decoding into a Swift `Double` (or `Double?`, if `nullable` - /// is set to `true`). - /// - /// > Important: This `Schema` provides a hint to the model that it should generate a - /// > double-precision floating-point number, a `double`, but only guarantees that the value will - /// > be a number. + /// This schema instructs the model to produce data of type `"NUMBER"`, which is suitable for + /// decoding into a Swift `Double` (or `Double?`, if `nullable` is set to `true`). /// /// - Parameters: /// - description: An optional description of what the number should contain or represent; may @@ -203,8 +197,6 @@ public class Schema { public static func double(description: String? = nil, nullable: Bool = false) -> Schema { return self.init( type: .number, - // TODO(andrewheard): Revert this change when the backend accepts "double" as a format again. - // format: "double", description: description, nullable: nullable ) From 007c7b4abbaa52eb8070e9fa9b254b04b2741d41 Mon Sep 17 00:00:00 2001 From: Andrew Heard Date: Tue, 5 Nov 2024 16:11:01 -0500 Subject: [PATCH 3/3] Add CHANGELOG entry --- FirebaseVertexAI/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/FirebaseVertexAI/CHANGELOG.md b/FirebaseVertexAI/CHANGELOG.md index 870f0c53788..b4a67aff89f 100644 --- a/FirebaseVertexAI/CHANGELOG.md +++ b/FirebaseVertexAI/CHANGELOG.md @@ -2,6 +2,9 @@ - [fixed] Fixed an issue where `VertexAI.vertexAI(app: app1)` and `VertexAI.vertexAI(app: app2)` would return the same instance if their `location` was the same, including the default `us-central1`. (#14007) +- [changed] Removed `format: "double"` in `Schema.double()` since + double-precision accuracy isn't enforced by the model; continue using the + Swift `Double` type when decoding data produced with this schema. (#13990) # 11.4.0 - [feature] Vertex AI in Firebase is now Generally Available (GA) and can be