Interface IAiManagerSPI

  • All Known Implementing Classes:
    OpenAiManager

    public interface IAiManagerSPI
    Provides AI related operations.
    Since:
    16.0.0
    Version:
    $Revision: 26318 $ $Date: 2024-04-11 16:45:43 -0300 (Thu, 11 Apr 2024) $
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void destroy()
      Destroys this manager.
      void init()
      Initializes this manager.
      default boolean isAiEnabled​(StructureElement structureElement)
      Returns whether the AI is enabled for the given structure element, based on the property bag lumis.portal.ai.enabled.
      boolean isAvailable()
      Returns whether this AI Manager is available to be used.
      void onEnvironmentConfigurationUpdate()
      Called when the EnvironmentConfiguration is updated.
      java.util.concurrent.CompletableFuture<java.lang.String> requestEditHtml​(java.lang.String inputHtml, java.lang.String instruction)
      Request AI to edit a HTML code according to the given instructions.
      java.util.concurrent.CompletableFuture<java.lang.String> requestEditHtmlText​(java.lang.String inputHtml, java.lang.String instruction)
      Request AI to edit the text inside a HTML code according to the given instructions.
      java.util.concurrent.CompletableFuture<java.lang.String> requestEditText​(java.lang.String inputText, java.lang.String instruction)
      Request AI to edit a text according to the given instructions.
    • Method Detail

      • init

        void init()
        Initializes this manager. This method is expected to be called during the LumisXP boot process.
        Since:
        16.0.0
      • destroy

        void destroy()
        Destroys this manager. This method frees resources used by this manager. This manager must not be used after this. This method is expected to be called during the LumisXP shutdown process.
        Since:
        %LUM_NEXT_VERSION%
      • isAvailable

        boolean isAvailable()
        Returns whether this AI Manager is available to be used.
        Returns:
        true if this manager is available for use, false if it is not, probably due to missing configuration.
        Since:
        16.0.0
      • onEnvironmentConfigurationUpdate

        void onEnvironmentConfigurationUpdate()
        Called when the EnvironmentConfiguration is updated. This is called on each server if it is a cluster environment.
        Since:
        16.0.0
      • requestEditText

        java.util.concurrent.CompletableFuture<java.lang.String> requestEditText​(java.lang.String inputText,
                                                                                 java.lang.String instruction)
                                                                          throws PortalException
        Request AI to edit a text according to the given instructions.
        Parameters:
        instructions - the instructions of how the edit should be done. Must not be empty.
        inputText - the text to edit.
        Returns:
        a future that will contain the resulting edited text.
        Throws:
        java.lang.IllegalStateException - if the AI is not available for use.
        PortalException - if the operation could not be executed.
        Since:
        16.0.0
      • requestEditHtml

        java.util.concurrent.CompletableFuture<java.lang.String> requestEditHtml​(java.lang.String inputHtml,
                                                                                 java.lang.String instruction)
                                                                          throws PortalException
        Request AI to edit a HTML code according to the given instructions.
        Parameters:
        instructions - the instructions of how the edit should be done. Must not be empty.
        inputHtml - the HTML code to edit.
        Returns:
        a future that will contain the resulting edited HTML code.
        Throws:
        java.lang.IllegalStateException - if the AI is not available for use.
        PortalException - if the operation could not be executed.
        Since:
        16.0.0
      • requestEditHtmlText

        java.util.concurrent.CompletableFuture<java.lang.String> requestEditHtmlText​(java.lang.String inputHtml,
                                                                                     java.lang.String instruction)
                                                                              throws PortalException
        Request AI to edit the text inside a HTML code according to the given instructions. Note that the underlying implementation may not give AI details about the HTML, so instructions that are not only about the text and that depends on the HTML structure may fail.
        Parameters:
        instructions - the instructions of how the edit should be done. Must not be empty.
        inputHtml - the HTML code to edit.
        Returns:
        a future that will contain the resulting edited HTML code.
        Throws:
        java.lang.IllegalStateException - if the AI is not available for use.
        PortalException - if the operation could not be executed.
        Since:
        16.0.0
      • isAiEnabled

        default boolean isAiEnabled​(StructureElement structureElement)
                             throws PortalException
        Returns whether the AI is enabled for the given structure element, based on the property bag lumis.portal.ai.enabled.
        Parameters:
        structureElement - the structure element.
        Returns:
        true if AI is enabled for that element, false otherwise.
        Throws:
        PortalException
        Since:
        16.0.0