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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexecuteCode(InvocationContext invocationContext, CodeExecutionUtils.CodeExecutionInput codeExecutionInput) Executes code and return 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 BaseCodeExecutor
codeBlockDelimiters, errorRetryAttempts, executionResultDelimitersMethods inherited from class JsonBaseModel
fromJsonNode, fromJsonString, getMapper, toJson, toJsonNode, toJsonString
-
Constructor Details
-
ContainerCodeExecutor
public ContainerCodeExecutor(Optional<String> baseUrl, Optional<String> image, Optional<String> dockerPath) Initializes the ContainerCodeExecutor.- Parameters:
baseUrl- Optional. The base url of the user hosted Docker client.image- The tag of the predefined image or custom image to run on the container. Either dockerPath or image must be set.dockerPath- The path to the directory containing the Dockerfile. If set, build the image from the dockerfile path instead of using the predefined image. Either dockerPath or image must be set.
-
-
Method Details
-
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.- Specified by:
executeCodein classBaseCodeExecutor- Parameters:
invocationContext- The invocation context of the code execution.codeExecutionInput- The code execution input.- Returns:
- The code execution result.
-