Class PromptQueryTestViewModel

  • All Implemented Interfaces:
    Serializable

    public class PromptQueryTestViewModel
    extends Object
    implements Serializable
    View model for testing a prompt query. Contains the information needed to render the test UI, such as the input parameters and file controls. It also contains the result of the latest test execution, if any.
    Since:
    8.5.0
    See Also:
    Serialized Form
    • Method Detail

      • getError

        public String getError()
        If this model represents an error state, gets the error message.
        Returns:
        The error message, or null if there is no error.
      • getFileControls

        public List<PromptTestFileInput> getFileControls()
        Gets the controls for editing the file inputs of the prompt query. The structure of the controls is based on the file input descriptor of the prompt query.
        Returns:
        The controls for editing the file inputs.
      • getJsonParameters

        public IValueAccessor<Object> getJsonParameters()
        Gets the JSON object with the configured input parameters, which needs to conform to the JSON input descriptor of the prompt query.
        Returns:
        The JSON object with the configured input parameters.
      • getLastExecutionResult

        public PromptQueryTestExecutionResult getLastExecutionResult()
        Gets the result of the last prompt query test execution, if any.
        Returns:
        The result of the last execution, or null if no execution has been performed yet.
      • isHasError

        public boolean isHasError()
        Checks whether this model represents an error state, i.e. when the test model could not be created properly, such as when the prompt service failed to return an input descriptor. If so, getError() returns the error message; and other methods such as getJsonPropertiesForm return empty or null values.
        Returns:
        True if this model represents an error state; false otherwise.
      • updateControls

        public void updateControls​(ValueDescriptorFormModel jsonPropertiesForm,
                                   List<PromptTestFileInput> fileControls)
        Updates this test view model with the given controls, i.e. changes the controls to the given ones and clears any previous error.
        Parameters:
        jsonPropertiesForm - The dynamic form model for the JSON input parameters of the selected prompt query.
        fileControls - The controls for editing the file parameters.
      • updateLastExecutionResult

        public void updateLastExecutionResult​(PromptQueryTestExecutionResult result)
        Updates this test view model with the given execution result from the latest prompt query test execution. Leaves all other properties unchanged.
        Parameters:
        result - The result of the latest prompt query test execution.
      • forControls

        public static PromptQueryTestViewModel forControls​(ValueDescriptorFormModel jsonPropertiesForm,
                                                           List<PromptTestFileInput> fileControls,
                                                           IValueAccessor<Object> jsonParameters,
                                                           Map<String,​List<PromptTestFile>> uploadedFiles)
        Creates a new view model for the prompt query action configuration UI; when the configuration could be loaded successfully.
        Parameters:
        jsonPropertiesForm - The dynamic form model for the JSON input parameters of the selected prompt query.
        fileControls - The controls for editing the file parameters.
        jsonParameters - The JSON object with the configured input parameters.
        uploadedFiles - The list with files that were uploaded for each file input.
      • forError

        public static PromptQueryTestViewModel forError​(String error)
        Creates a new view model for the prompt query action configuration UI; when an error occurred.
        Parameters:
        error - The error message.