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, executionResultDelimitersMethods inherited from class JsonBaseModel
fromJsonNode, fromJsonString, getMapper, toJson, toJsonNode, toJsonString
-
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.
-