FunctionDeclaration
Defines a function that the model can use as a tool.
When generating responses, the model might need external information or require the application to perform an action. FunctionDeclaration provides the necessary information for the model to create a FunctionCallPart, which instructs the client to execute the corresponding function. The client then sends the result back to the model as a FunctionResponsePart.
For example
val getExchangeRate = FunctionDeclaration(
name = "getExchangeRate",
description = "Get the exchange rate for currencies between countries.",
parameters = mapOf(
"currencyFrom" to Schema.str("The currency to convert from."),
"currencyTo" to Schema.str("The currency to convert to.")
)
)See the Use the Gemini API for function calling guide for more information on function calling.
Parameters
The name of the function.
The description of what the function does and its output. To improve the effectiveness of the model, the description should be clear and detailed.
The map of parameters names to their Schema the function accepts as arguments.
The list of parameter names that the model can omit when invoking this function.