Class Functions
java.lang.Object
com.google.adk.flows.llmflows.Functions
Utility class for handling function calls.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringGenerates a unique ID for a function call.generateRequestConfirmationEvent(InvocationContext invocationContext, Event functionCallEvent, Event functionResponseEvent) Generates a request confirmation event from a function response event.static com.google.common.collect.ImmutableList<com.google.genai.types.FunctionCall> Gets the ask user confirmation function calls from the event.getLongRunningFunctionCalls(List<com.google.genai.types.FunctionCall> functionCalls, Map<String, BaseTool> tools) static io.reactivex.rxjava3.core.Maybe<Event> handleFunctionCalls(InvocationContext invocationContext, Event functionCallEvent, Map<String, BaseTool> tools) Handles standard, non-streaming function calls.static io.reactivex.rxjava3.core.Maybe<Event> handleFunctionCalls(InvocationContext invocationContext, Event functionCallEvent, Map<String, BaseTool> tools, Map<String, ToolConfirmation> toolConfirmations) Handles standard, non-streaming function calls with tool confirmations.static io.reactivex.rxjava3.core.Maybe<Event> handleFunctionCallsLive(InvocationContext invocationContext, Event functionCallEvent, Map<String, BaseTool> tools) Handles function calls in a live/streaming context, supporting background execution and stream termination.static io.reactivex.rxjava3.core.Maybe<Event> handleFunctionCallsLive(InvocationContext invocationContext, Event functionCallEvent, Map<String, BaseTool> tools, Map<String, ToolConfirmation> toolConfirmations) Handles function calls in a live/streaming context with tool confirmations, supporting background execution and stream termination.static voidpopulateClientFunctionCallId(Event modelResponseEvent) Populates missing function call IDs in the provided event's content.
-
Field Details
-
REQUEST_CONFIRMATION_FUNCTION_CALL_NAME
The function call name for the request confirmation function.- See Also:
-
TOOL_CALL_SECURITY_STATES
Session state key for storing the security policy outcomes for tool calls.- See Also:
-
-
Method Details
-
generateClientFunctionCallId
Generates a unique ID for a function call. -
populateClientFunctionCallId
Populates missing function call IDs in the provided event's content.If the event contains function calls without an ID, this method generates a unique client-side ID for each and updates the event content.
- Parameters:
modelResponseEvent- The event potentially containing function calls.
-
handleFunctionCalls
-
handleFunctionCalls
public static io.reactivex.rxjava3.core.Maybe<Event> handleFunctionCalls(InvocationContext invocationContext, Event functionCallEvent, Map<String, BaseTool> tools, Map<String, ToolConfirmation> toolConfirmations) Handles standard, non-streaming function calls with tool confirmations. -
handleFunctionCallsLive
-
handleFunctionCallsLive
public static io.reactivex.rxjava3.core.Maybe<Event> handleFunctionCallsLive(InvocationContext invocationContext, Event functionCallEvent, Map<String, BaseTool> tools, Map<String, ToolConfirmation> toolConfirmations) Handles function calls in a live/streaming context with tool confirmations, supporting background execution and stream termination. -
getLongRunningFunctionCalls
-
generateRequestConfirmationEvent
public static Optional<Event> generateRequestConfirmationEvent(InvocationContext invocationContext, Event functionCallEvent, Event functionResponseEvent) Generates a request confirmation event from a function response event.- Parameters:
invocationContext- The invocation context.functionCallEvent- The event containing the original function call.functionResponseEvent- The event containing the function response.- Returns:
- An optional event containing the request confirmation function call.
-
getAskUserConfirmationFunctionCalls
public static com.google.common.collect.ImmutableList<com.google.genai.types.FunctionCall> getAskUserConfirmationFunctionCalls(Event event) Gets the ask user confirmation function calls from the event.- Parameters:
event- The event to extract function calls from.- Returns:
- A list of function calls for asking user confirmation.
-