Class BuiltInCodeExecutor
java.lang.Object
com.google.adk.JsonBaseModel
com.google.adk.codeexecutors.BaseCodeExecutor
com.google.adk.codeexecutors.BuiltInCodeExecutor
A code executor that uses the Model's built-in code executor.
Currently only supports Gemini 2.0+ models, but will be expanded to other models.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexecuteCode(InvocationContext invocationContext, CodeExecutionUtils.CodeExecutionInput codeExecutionInput) Executes code and return the code execution result.voidprocessLlmRequest(LlmRequest.Builder llmRequestBuilder) Pre-process the LLM request for Gemini 2.0+ models to use the code execution tool.Methods inherited from class BaseCodeExecutor
codeBlockDelimiters, errorRetryAttempts, executionResultDelimiters, optimizeDataFile, statefulModifier and TypeMethodDescriptioncom.google.common.collect.ImmutableList<com.google.common.collect.ImmutableList<String>> The list of the enclosing delimiters to identify the code blocks.intThe number of attempts to retry on consecutive code execution errors.com.google.common.collect.ImmutableList<String> The delimiters to format the code execution result.booleanIf true, extract and process data files from the model request and attach them to the code executor.booleanstateful()Whether the code executor is stateful.Methods inherited from class JsonBaseModel
fromJsonNode, fromJsonString, getMapper, toJson, toJsonNode, toJsonStringModifier and TypeMethodDescriptionstatic <T extends JsonBaseModel>
TfromJsonNode(com.fasterxml.jackson.databind.JsonNode jsonNode, Class<T> clazz) Deserializes a JsonNode to an object of the given type.static <T extends JsonBaseModel>
TfromJsonString(String jsonString, Class<T> clazz) Deserializes a Json string to an object of the given type.static com.fasterxml.jackson.databind.ObjectMapperReturns the mutable ObjectMapper instance used by ADK.toJson()Serializes this object (i.e., the ObjectMappper instance used by ADK) to a Json string.protected static com.fasterxml.jackson.databind.JsonNodetoJsonNode(Object object) Serializes an object to a JsonNode.static StringtoJsonString(Object object) Serializes an object to a Json string.
-
Constructor Details
-
BuiltInCodeExecutor
public BuiltInCodeExecutor()
-
-
Method Details
-
executeCode
public CodeExecutionUtils.CodeExecutionResult executeCode(InvocationContext invocationContext, CodeExecutionUtils.CodeExecutionInput codeExecutionInput) Description copied from class:BaseCodeExecutorExecutes code and return the code execution result.This method may perform blocking operations.
- Specified by:
executeCodein classBaseCodeExecutor- Parameters:
invocationContext- The invocation context of the code execution.codeExecutionInput- The code execution input.- Returns:
- The code execution result.
-
processLlmRequest
Pre-process the LLM request for Gemini 2.0+ models to use the code execution tool.
-