Class SerializedPromptConfig.Builder

java.lang.Object
de.xima.fc.prompt.service.SerializedPromptConfig.Builder
Enclosing class:
SerializedPromptConfig

public static final class SerializedPromptConfig.Builder extends Object
A builder for creating instances of SerializedPromptConfig.

Example usage:

SerializedPromptConfig config = SerializedPromptConfig.builder()
        .addBinaryData("fileKey", promptBinaryData)
        .addTextData("textKey", "Some text")
        .build();
Since:
8.5.0
  • Method Details

    • addBinaryData

      @CanIgnoreReturnValue public SerializedPromptConfig.Builder addBinaryData(Map<String, List<IPromptBinaryData>> binaryData)
      Adds binary data to the existing binary data map. If values exists already for a key, the new data is appended to the existing values.
      Parameters:
      binaryData - The binary data to add.
      Returns:
      This builder instance for method chaining.
    • addBinaryData

      @CanIgnoreReturnValue public SerializedPromptConfig.Builder addBinaryData(String key, IPromptBinaryData value)
      Adds a single binary data object to the existing binary data map for the specified key. If the key already has values, the new value is appended to the existing list.
      Parameters:
      key - The key for which to store the binary data. If null or empty, it will be ignored.
      value - The binary data object to add. If null, it will be ignored.
      Returns:
      This builder instance for method chaining.
    • addBinaryData

      @CanIgnoreReturnValue public SerializedPromptConfig.Builder addBinaryData(String key, List<IPromptBinaryData> values)
      Adds a list of binary data objects to the existing binary data map for the specified key. If the key already has values, the new values are appended to the existing list.
      Parameters:
      key - The key for which to store the binary data. If null or empty, it will be ignored.
      values - The list of binary data objects to add. If null, it will be ignored.
      Returns:
      This builder instance for method chaining.
    • addTextData

      @CanIgnoreReturnValue public SerializedPromptConfig.Builder addTextData(Map<String, List<String>> textData)
      Adds text data to the existing text data map. If values exists already for a key, the new data is appended to the existing values.
      Parameters:
      textData - The text data to add.
      Returns:
      This builder instance for method chaining.
    • addTextData

      @CanIgnoreReturnValue public SerializedPromptConfig.Builder addTextData(String key, String value)
      Adds a single text value to the existing text data map for the specified key. If the key already has values, the new value is appended to the existing list.
      Parameters:
      key - The key for which to store the text value. If null or empty, it will be ignored.
      value - The text value to add. If null, it will be ignored.
      Returns:
      This builder instance for method chaining.
    • addTextData

      @CanIgnoreReturnValue public SerializedPromptConfig.Builder addTextData(String key, List<String> value)
      Adds a list of text values to the existing text data map for the specified key. If the key already has values, the new values are appended to the existing list.
      Parameters:
      key - The key for which to store the text values. If null or empty, it will be ignored.
      value - The list of text values to add. If null, it will be ignored.
      Returns:
      This builder instance for method chaining.
    • binaryData

      @CanIgnoreReturnValue public SerializedPromptConfig.Builder binaryData(String key, List<IPromptBinaryData> values)
      Sets the binary data for the specified key to a list of values. If values already exist for the key, they are cleared and replaced with the new values.
      Parameters:
      key - The key for which to set the binary data. If null or empty, it will be ignored.
      values - The list of binary data objects to set. If null, sets the key to an empty list.
      Returns:
      This builder instance for method chaining.
    • binaryData

      @CanIgnoreReturnValue public SerializedPromptConfig.Builder binaryData(String key, IPromptBinaryData value)
      Sets the binary data for the specified key to a single value. If values already exist for the key, they are cleared and replaced with the new value.
      Parameters:
      key - The key for which to set the binary data. If null or empty, it will be ignored.
      value - The binary data object to set. If null, sets the key to an empty list.
      Returns:
      This builder instance for method chaining.
    • binaryData

      @CanIgnoreReturnValue public SerializedPromptConfig.Builder binaryData(Map<String, List<IPromptBinaryData>> binaryData)
      Clears all existing binary data and replaces it with the provided binary data.
      Parameters:
      binaryData - The new binary data to set.
      Returns:
      This builder instance for method chaining.
    • binaryData

      public List<IPromptBinaryData> binaryData(String key)
      Gets the binary data associated with the given key, or an empty list if no such value exists.
      Parameters:
      key - The key to look up.
      Returns:
      A list with the binary data associated with the key, or an empty list if not found.
    • binaryDataKeys

      public Set<String> binaryDataKeys()
      Gets the keys of all binary data entries in this builder.
      Returns:
      A set of keys representing the binary data entries.
    • build

      @CanIgnoreReturnValue public SerializedPromptConfig build()
      Builds a new SerializedPromptConfig instance with the current state of this builder. Subsequent modifications to this builder will not affect the created instance.
      Returns:
      A new instance of serialized prompt configuration with the current data.
    • firstBinaryData

      public IPromptBinaryData firstBinaryData(String key)
      Gets the first binary data associated with the given key, or null if no such value exists.
      Parameters:
      key - The key to look up.
      Returns:
      The first binary data associated with the key, or null if not found.
    • firstTextData

      public String firstTextData(String key)
      Gets the first text data associated with the given key, or null if no such value exists.
      Parameters:
      key - The key to look up.
      Returns:
      The first text data associated with the key, or null if not found.
    • textData

      public List<String> textData(String key)
      Gets the text data associated with the given key, or an empty list if no such value exists.
      Parameters:
      key - The key to look up.
      Returns:
      A list with the text data associated with the key, or an empty list if not found.
    • textData

      @CanIgnoreReturnValue public SerializedPromptConfig.Builder textData(String key, String value)
      Sets the text data for the specified key to a single value. If values already exist for the key, they are cleared and replaced with the new value.
      Parameters:
      key - The key for which to set the text value. If null or empty, it will be ignored.
      value - The text value to set. If null, sets the key to an empty list.
      Returns:
      This builder instance for method chaining.
    • textData

      @CanIgnoreReturnValue public SerializedPromptConfig.Builder textData(String key, List<String> values)
      Sets the text data for the specified key to a list of values. If values already exist for the key, they are cleared and replaced with the new values.
      Parameters:
      key - The key for which to set the text data. If null or empty, it will be ignored.
      values - The list of text values to set. If null, sets the key to an empty list.
      Returns:
      This builder instance for method chaining.
    • textData

      @CanIgnoreReturnValue public SerializedPromptConfig.Builder textData(Map<String, List<String>> textData)
      Clears all existing text data and replaces it with the provided text data.
      Parameters:
      textData - The new text data to set.
      Returns:
      This builder instance for method chaining.
    • textDataKeys

      public Set<String> textDataKeys()
      Gets the keys of all text data entries in this builder.
      Returns:
      A set of keys representing the text data entries.