Class VertexAiCodeExecutor
java.lang.Object
com.google.adk.JsonBaseModel
com.google.adk.codeexecutors.BaseCodeExecutor
com.google.adk.codeexecutors.VertexAiCodeExecutor
A code executor that uses Vertex Code Interpreter Extension to execute code.
Attributes: resourceName: If set, load the existing resource name of the code interpreter extension instead of creating a new one. Format: projects/123/locations/us-central1/extensions/456
Follow https://cloud.google.com/vertex-ai/generative-ai/docs/extensions/code-interpreter for setup.
-
Constructor Summary
ConstructorsConstructorDescriptionVertexAiCodeExecutor(String resourceName) Initializes the VertexAiCodeExecutor. -
Method Summary
Modifier and TypeMethodDescriptionexecuteCode(InvocationContext invocationContext, CodeExecutionUtils.CodeExecutionInput codeExecutionInput) Executes code and return the code execution result.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
-
VertexAiCodeExecutor
Initializes the VertexAiCodeExecutor.- Parameters:
resourceName- If set, load the existing resource name of the code interpreter extension instead of creating a new one. Format: projects/123/locations/us-central1/extensions/456
-
-
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.
-