Class CustomCodeExecutionSpec.Builder

java.lang.Object
com.google.protobuf.AbstractMessageLite.Builder
com.google.protobuf.AbstractMessage.Builder<BuilderT>
com.google.protobuf.GeneratedMessage.Builder<CustomCodeExecutionSpec.Builder>
com.google.cloud.aiplatform.v1beta1.CustomCodeExecutionSpec.Builder
All Implemented Interfaces:
CustomCodeExecutionSpecOrBuilder, com.google.protobuf.Message.Builder, com.google.protobuf.MessageLite.Builder, com.google.protobuf.MessageLiteOrBuilder, com.google.protobuf.MessageOrBuilder, Cloneable
Enclosing class:
CustomCodeExecutionSpec

public static final class CustomCodeExecutionSpec.Builder extends com.google.protobuf.GeneratedMessage.Builder<CustomCodeExecutionSpec.Builder> implements CustomCodeExecutionSpecOrBuilder
 Specificies a metric that is populated by evaluating user-defined Python
 code.
 
Protobuf type google.cloud.aiplatform.v1beta1.CustomCodeExecutionSpec
  • Method Details

    • getDescriptor

      public static final com.google.protobuf.Descriptors.Descriptor getDescriptor()
    • internalGetFieldAccessorTable

      protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable()
      Specified by:
      internalGetFieldAccessorTable in class com.google.protobuf.GeneratedMessage.Builder<CustomCodeExecutionSpec.Builder>
    • clear

      Specified by:
      clear in interface com.google.protobuf.Message.Builder
      Specified by:
      clear in interface com.google.protobuf.MessageLite.Builder
      Overrides:
      clear in class com.google.protobuf.GeneratedMessage.Builder<CustomCodeExecutionSpec.Builder>
    • getDescriptorForType

      public com.google.protobuf.Descriptors.Descriptor getDescriptorForType()
      Specified by:
      getDescriptorForType in interface com.google.protobuf.Message.Builder
      Specified by:
      getDescriptorForType in interface com.google.protobuf.MessageOrBuilder
      Overrides:
      getDescriptorForType in class com.google.protobuf.GeneratedMessage.Builder<CustomCodeExecutionSpec.Builder>
    • getDefaultInstanceForType

      public CustomCodeExecutionSpec getDefaultInstanceForType()
      Specified by:
      getDefaultInstanceForType in interface com.google.protobuf.MessageLiteOrBuilder
      Specified by:
      getDefaultInstanceForType in interface com.google.protobuf.MessageOrBuilder
    • build

      public CustomCodeExecutionSpec build()
      Specified by:
      build in interface com.google.protobuf.Message.Builder
      Specified by:
      build in interface com.google.protobuf.MessageLite.Builder
    • buildPartial

      public CustomCodeExecutionSpec buildPartial()
      Specified by:
      buildPartial in interface com.google.protobuf.Message.Builder
      Specified by:
      buildPartial in interface com.google.protobuf.MessageLite.Builder
    • mergeFrom

      public CustomCodeExecutionSpec.Builder mergeFrom(com.google.protobuf.Message other)
      Specified by:
      mergeFrom in interface com.google.protobuf.Message.Builder
      Overrides:
      mergeFrom in class com.google.protobuf.AbstractMessage.Builder<CustomCodeExecutionSpec.Builder>
    • mergeFrom

    • isInitialized

      public final boolean isInitialized()
      Specified by:
      isInitialized in interface com.google.protobuf.MessageLiteOrBuilder
      Overrides:
      isInitialized in class com.google.protobuf.GeneratedMessage.Builder<CustomCodeExecutionSpec.Builder>
    • mergeFrom

      public CustomCodeExecutionSpec.Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws IOException
      Specified by:
      mergeFrom in interface com.google.protobuf.Message.Builder
      Specified by:
      mergeFrom in interface com.google.protobuf.MessageLite.Builder
      Overrides:
      mergeFrom in class com.google.protobuf.AbstractMessage.Builder<CustomCodeExecutionSpec.Builder>
      Throws:
      IOException
    • hasEvaluationFunction

      public boolean hasEvaluationFunction()
       Required. Python function.
       Expected user to define the following function, e.g.:
       def evaluate(instance: dict[str, Any]) -> float:
       Please include this function signature in the code snippet.
       Instance is the evaluation instance, any fields populated in the instance
       are available to the function as instance[field_name].
      
       Example:
       Example input:
       ```
       instance= EvaluationInstance(
       response=EvaluationInstance.InstanceData(text="The answer is 4."),
       reference=EvaluationInstance.InstanceData(text="4")
       )
       ```
      
       Example converted input:
       ```
       {
       'response': {'text': 'The answer is 4.'},
       'reference': {'text': '4'}
       }
       ```
      
       Example python function:
       ```
       def evaluate(instance: dict[str, Any]) -> float:
       if instance['response']['text'] == instance['reference']['text']:
       return 1.0
       return 0.0
       ```
      
       CustomCodeExecutionSpec is also supported in Batch Evaluation (EvalDataset
       RPC) and Tuning Evaluation. Each line in the input jsonl file will be
       converted to dict[str, Any] and passed to the evaluation function.
       
      optional string evaluation_function = 1 [(.google.api.field_behavior) = REQUIRED];
      Specified by:
      hasEvaluationFunction in interface CustomCodeExecutionSpecOrBuilder
      Returns:
      Whether the evaluationFunction field is set.
    • getEvaluationFunction

      public String getEvaluationFunction()
       Required. Python function.
       Expected user to define the following function, e.g.:
       def evaluate(instance: dict[str, Any]) -> float:
       Please include this function signature in the code snippet.
       Instance is the evaluation instance, any fields populated in the instance
       are available to the function as instance[field_name].
      
       Example:
       Example input:
       ```
       instance= EvaluationInstance(
       response=EvaluationInstance.InstanceData(text="The answer is 4."),
       reference=EvaluationInstance.InstanceData(text="4")
       )
       ```
      
       Example converted input:
       ```
       {
       'response': {'text': 'The answer is 4.'},
       'reference': {'text': '4'}
       }
       ```
      
       Example python function:
       ```
       def evaluate(instance: dict[str, Any]) -> float:
       if instance['response']['text'] == instance['reference']['text']:
       return 1.0
       return 0.0
       ```
      
       CustomCodeExecutionSpec is also supported in Batch Evaluation (EvalDataset
       RPC) and Tuning Evaluation. Each line in the input jsonl file will be
       converted to dict[str, Any] and passed to the evaluation function.
       
      optional string evaluation_function = 1 [(.google.api.field_behavior) = REQUIRED];
      Specified by:
      getEvaluationFunction in interface CustomCodeExecutionSpecOrBuilder
      Returns:
      The evaluationFunction.
    • getEvaluationFunctionBytes

      public com.google.protobuf.ByteString getEvaluationFunctionBytes()
       Required. Python function.
       Expected user to define the following function, e.g.:
       def evaluate(instance: dict[str, Any]) -> float:
       Please include this function signature in the code snippet.
       Instance is the evaluation instance, any fields populated in the instance
       are available to the function as instance[field_name].
      
       Example:
       Example input:
       ```
       instance= EvaluationInstance(
       response=EvaluationInstance.InstanceData(text="The answer is 4."),
       reference=EvaluationInstance.InstanceData(text="4")
       )
       ```
      
       Example converted input:
       ```
       {
       'response': {'text': 'The answer is 4.'},
       'reference': {'text': '4'}
       }
       ```
      
       Example python function:
       ```
       def evaluate(instance: dict[str, Any]) -> float:
       if instance['response']['text'] == instance['reference']['text']:
       return 1.0
       return 0.0
       ```
      
       CustomCodeExecutionSpec is also supported in Batch Evaluation (EvalDataset
       RPC) and Tuning Evaluation. Each line in the input jsonl file will be
       converted to dict[str, Any] and passed to the evaluation function.
       
      optional string evaluation_function = 1 [(.google.api.field_behavior) = REQUIRED];
      Specified by:
      getEvaluationFunctionBytes in interface CustomCodeExecutionSpecOrBuilder
      Returns:
      The bytes for evaluationFunction.
    • setEvaluationFunction

      public CustomCodeExecutionSpec.Builder setEvaluationFunction(String value)
       Required. Python function.
       Expected user to define the following function, e.g.:
       def evaluate(instance: dict[str, Any]) -> float:
       Please include this function signature in the code snippet.
       Instance is the evaluation instance, any fields populated in the instance
       are available to the function as instance[field_name].
      
       Example:
       Example input:
       ```
       instance= EvaluationInstance(
       response=EvaluationInstance.InstanceData(text="The answer is 4."),
       reference=EvaluationInstance.InstanceData(text="4")
       )
       ```
      
       Example converted input:
       ```
       {
       'response': {'text': 'The answer is 4.'},
       'reference': {'text': '4'}
       }
       ```
      
       Example python function:
       ```
       def evaluate(instance: dict[str, Any]) -> float:
       if instance['response']['text'] == instance['reference']['text']:
       return 1.0
       return 0.0
       ```
      
       CustomCodeExecutionSpec is also supported in Batch Evaluation (EvalDataset
       RPC) and Tuning Evaluation. Each line in the input jsonl file will be
       converted to dict[str, Any] and passed to the evaluation function.
       
      optional string evaluation_function = 1 [(.google.api.field_behavior) = REQUIRED];
      Parameters:
      value - The evaluationFunction to set.
      Returns:
      This builder for chaining.
    • clearEvaluationFunction

      public CustomCodeExecutionSpec.Builder clearEvaluationFunction()
       Required. Python function.
       Expected user to define the following function, e.g.:
       def evaluate(instance: dict[str, Any]) -> float:
       Please include this function signature in the code snippet.
       Instance is the evaluation instance, any fields populated in the instance
       are available to the function as instance[field_name].
      
       Example:
       Example input:
       ```
       instance= EvaluationInstance(
       response=EvaluationInstance.InstanceData(text="The answer is 4."),
       reference=EvaluationInstance.InstanceData(text="4")
       )
       ```
      
       Example converted input:
       ```
       {
       'response': {'text': 'The answer is 4.'},
       'reference': {'text': '4'}
       }
       ```
      
       Example python function:
       ```
       def evaluate(instance: dict[str, Any]) -> float:
       if instance['response']['text'] == instance['reference']['text']:
       return 1.0
       return 0.0
       ```
      
       CustomCodeExecutionSpec is also supported in Batch Evaluation (EvalDataset
       RPC) and Tuning Evaluation. Each line in the input jsonl file will be
       converted to dict[str, Any] and passed to the evaluation function.
       
      optional string evaluation_function = 1 [(.google.api.field_behavior) = REQUIRED];
      Returns:
      This builder for chaining.
    • setEvaluationFunctionBytes

      public CustomCodeExecutionSpec.Builder setEvaluationFunctionBytes(com.google.protobuf.ByteString value)
       Required. Python function.
       Expected user to define the following function, e.g.:
       def evaluate(instance: dict[str, Any]) -> float:
       Please include this function signature in the code snippet.
       Instance is the evaluation instance, any fields populated in the instance
       are available to the function as instance[field_name].
      
       Example:
       Example input:
       ```
       instance= EvaluationInstance(
       response=EvaluationInstance.InstanceData(text="The answer is 4."),
       reference=EvaluationInstance.InstanceData(text="4")
       )
       ```
      
       Example converted input:
       ```
       {
       'response': {'text': 'The answer is 4.'},
       'reference': {'text': '4'}
       }
       ```
      
       Example python function:
       ```
       def evaluate(instance: dict[str, Any]) -> float:
       if instance['response']['text'] == instance['reference']['text']:
       return 1.0
       return 0.0
       ```
      
       CustomCodeExecutionSpec is also supported in Batch Evaluation (EvalDataset
       RPC) and Tuning Evaluation. Each line in the input jsonl file will be
       converted to dict[str, Any] and passed to the evaluation function.
       
      optional string evaluation_function = 1 [(.google.api.field_behavior) = REQUIRED];
      Parameters:
      value - The bytes for evaluationFunction to set.
      Returns:
      This builder for chaining.