Class ContainerCodeExecutor
java.lang.Object
com.google.adk.JsonBaseModel
com.google.adk.codeexecutors.BaseCodeExecutor
com.google.adk.codeexecutors.ContainerCodeExecutor
A code executor that uses a custom container to execute code.
-
Constructor Summary
ConstructorsConstructorDescriptionContainerCodeExecutor(String baseUrl, String image, String dockerPath) Deprecated.Use one of the static factory methods instead. -
Method Summary
Modifier and TypeMethodDescriptionexecuteCode(InvocationContext invocationContext, CodeExecutionUtils.CodeExecutionInput codeExecutionInput) Executes code and return the code execution result.static ContainerCodeExecutorfromDockerPath(String dockerPath) Creates a ContainerCodeExecutor from a Dockerfile path.static ContainerCodeExecutorfromDockerPath(String baseUrl, String dockerPath) Creates a ContainerCodeExecutor from a Dockerfile path.static ContainerCodeExecutorCreates a ContainerCodeExecutor from an image.static ContainerCodeExecutorCreates a ContainerCodeExecutor from an image.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 BaseCodeExecutor
codeBlockDelimiters, errorRetryAttempts, executionResultDelimitersModifier 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.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
-
ContainerCodeExecutor
Deprecated.Use one of the static factory methods instead.Initializes the ContainerCodeExecutor. Either dockerPath or image must be set.
-
-
Method Details
-
fromImage
Creates a ContainerCodeExecutor from an image.- Parameters:
baseUrl- The base url of the user hosted Docker client.image- The tag of the predefined image or custom image to run on the container.
-
fromImage
Creates a ContainerCodeExecutor from an image.- Parameters:
image- The tag of the predefined image or custom image to run on the container.
-
fromDockerPath
Creates a ContainerCodeExecutor from a Dockerfile path.- Parameters:
baseUrl- The base url of the user hosted Docker client.dockerPath- The path to the directory containing the Dockerfile.
-
fromDockerPath
Creates a ContainerCodeExecutor from a Dockerfile path.- Parameters:
dockerPath- The path to the directory containing the Dockerfile.
-
stateful
public boolean stateful()Description copied from class:BaseCodeExecutorWhether the code executor is stateful. Default to False.- Overrides:
statefulin classBaseCodeExecutor
-
optimizeDataFile
public boolean optimizeDataFile()Description copied from class:BaseCodeExecutorIf true, extract and process data files from the model request and attach them to the code executor.Supported data file MimeTypes are [text/csv]. Default to False.
- Overrides:
optimizeDataFilein classBaseCodeExecutor
-
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.
-