FirebaseAI Framework Reference
Stay organized with collections
Save and categorize content based on your preferences.
FunctionDeclaration
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
public struct FunctionDeclaration : Sendable
extension FunctionDeclaration: Encodable
Structured representation of a function declaration.
This FunctionDeclaration
is a representation of a block of code that can be used as a Tool
by the model and executed by the client.
-
Constructs a new FunctionDeclaration
.
Declaration
Swift
public init(name: String, description: String, parameters: [String: Schema],
optionalParameters: [String] = [])
Parameters
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.
|
optionalParameters
|
The names of parameters that may be omitted by the model in function
calls; by default, all parameters are considered required.
|
-
Declaration
Swift
public func encode(to encoder: Encoder) throws
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-20 UTC.
[null,null,["Last updated 2025-05-20 UTC."],[],[],null,["# FirebaseAI Framework Reference\n\nFunctionDeclaration\n===================\n\n @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)\n public struct FunctionDeclaration : Sendable\n\n extension FunctionDeclaration: Encodable\n\nStructured representation of a function declaration.\n\nThis `FunctionDeclaration` is a representation of a block of code that can be used as a [Tool](../Structs/Tool.html)\nby the model and executed by the client.\n- `\n ``\n ``\n `\n\n ### [init(name:description:parameters:optionalParameters:)](#/s:10FirebaseAI19FunctionDeclarationV4name11description10parameters18optionalParametersACSS_SSSDySSAA6SchemaCGSaySSGtcfc)\n\n `\n ` \n Constructs a new `FunctionDeclaration`. \n\n #### Declaration\n\n Swift \n\n public init(name: String, description: String, parameters: [String: ../Classes/Schema.html],\n optionalParameters: [String] = [])\n\n #### Parameters\n\n |----------------------------|---------------------------------------------------------------------------------------------------------------------------------|\n | ` `*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. |\n | ` `*description*` ` | A brief description of the function. |\n | ` `*parameters*` ` | Describes the parameters to this function. |\n | ` `*optionalParameters*` ` | The names of parameters that may be omitted by the model in function calls; by default, all parameters are considered required. |\n\n[Codable Conformance\n-------------------](#/Codable-Conformance)\n\n- `\n ``\n ``\n `\n\n ### [encode(to:)](#/s:SE6encode2toys7Encoder_p_tKF)\n\n `\n ` \n\n #### Declaration\n\n Swift \n\n public func encode(to encoder: Encoder) throws"]]