AutoFunctionDeclaration

public final class AutoFunctionDeclaration<I extends Object, O extends Object>


Defines a function that the model can use as a tool. Including a function references to enable automatic function calling.

When generating responses, the model might need external information or require the application to perform an action. AutoFunctionDeclaration 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 = AutoFunctionDeclaration.create(
name = "getExchangeRate",
description = "Get the exchange rate for currencies between countries.",
inputSchema = CurrencyRequest.schema,
outputSchema = CurrencyResponse.schema,
) {
// make an api request to convert currencies and return the result
}
See also
JsonSchema

Summary

Nested types

Public fields

description

public final @NonNull String description

functionReference

public final SuspendFunction1<@NonNull I, @NonNull O> functionReference

inputSchema

public final @NonNull JsonSchema<@NonNull I> inputSchema

name

public final @NonNull String name

outputSchema

public final JsonSchema<@NonNull O> outputSchema