Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vertex AI] Refactor Schema declarations #13616

Merged
merged 11 commits into from
Sep 25, 2024
7 changes: 7 additions & 0 deletions FirebaseVertexAI/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
renamed to `inlineData`; no functionality changes. (#13700)
- [changed] **Breaking Change**: The property `citationSources` of
`CitationMetadata` has been renamed to `citations`. (#13702)
- [changed] **Breaking Change**: The constructor for `Schema` is now deprecated;
use the new static methods `Schema.string(...)`, `Schema.object(...)`, etc.,
instead. (#13616)
- [changed] **Breaking Change**: The constructor for `FunctionDeclaration` now
accepts an array of *optional* parameters instead of a list of *required*
parameters; if a parameter is not listed as optional it is assumed to be
required. (#13616)

# 11.3.0
- [added] Added `Decodable` conformance for `FunctionResponse`. (#13606)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,15 @@ class FunctionCallingViewModel: ObservableObject {
name: "get_exchange_rate",
description: "Get the exchange rate for currencies between countries",
parameters: [
andrewheard marked this conversation as resolved.
Show resolved Hide resolved
"currency_from": Schema(
type: .string,
format: "enum",
description: "The currency to convert from in ISO 4217 format",
enumValues: ["USD", "EUR", "JPY", "GBP", "AUD", "CAD"]
"currency_from": .enumeration(
values: ["USD", "EUR", "JPY", "GBP", "AUD", "CAD"],
description: "The currency to convert from in ISO 4217 format"
),
"currency_to": Schema(
type: .string,
format: "enum",
description: "The currency to convert to in ISO 4217 format",
enumValues: ["USD", "EUR", "JPY", "GBP", "AUD", "CAD"]
"currency_to": .enumeration(
values: ["USD", "EUR", "JPY", "GBP", "AUD", "CAD"],
description: "The currency to convert to in ISO 4217 format"
),
],
requiredParameters: ["currency_from", "currency_to"]
]
),
])]
)
Expand Down
14 changes: 6 additions & 8 deletions FirebaseVertexAI/Sources/FunctionCalling.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,15 @@ public struct FunctionDeclaration {
/// - name: The name of the function; must be a-z, A-Z, 0-9, or contain underscores and dashes,
/// with a maximum length of 63.
/// - description: A brief description of the function.
/// - parameters: Describes the parameters to this function; the keys are parameter names and
/// the values are ``Schema`` objects describing them.
/// - requiredParameters: A list of required parameters by name.
public init(name: String, description: String, parameters: [String: Schema]?,
requiredParameters: [String]? = nil) {
/// - parameters: Describes the parameters to this function.
public init(name: String, description: String, parameters: [String: Schema],
optionalParameters: [String] = []) {
self.name = name
self.description = description
self.parameters = Schema(
type: .object,
self.parameters = Schema.object(
properties: parameters,
requiredProperties: requiredParameters
optionalProperties: optionalParameters,
nullable: false
)
}
}
Expand Down
Loading
Loading