Interface IAiManagerSPI

  • All Known Implementing Classes:
    OpenAiManager

    public interface IAiManagerSPI
    Provides AI related operations.
    Since:
    16.0.0
    Version:
    $Revision: 26156 $ $Date: 2024-01-13 10:26:46 -0300 (Sat, 13 Jan 2024) $
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String PROPERTY_AI_ENABLED
      Name of the property that can be set on a property bag with a value of false to disable AI in that structure.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void destroy()
      Destroys this manager.
      java.util.List<java.lang.Float> generateEmbeddings​(java.lang.String text)
      Generates embeddings for the given text.
      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 onConfigurationUpdate()
      Called when the AiConfig 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.
    • Field Detail

      • PROPERTY_AI_ENABLED

        static final java.lang.String PROPERTY_AI_ENABLED
        Name of the property that can be set on a property bag with a value of false to disable AI in that structure.
        Since:
        16.1.0
        See Also:
        Constant Field Values
    • 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:
        16.1.0
      • 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
      • onConfigurationUpdate

        void onConfigurationUpdate()
        Called when the AiConfig is updated.
        Since:
        16.1.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
      • generateEmbeddings

        java.util.List<java.lang.Float> generateEmbeddings​(java.lang.String text)
                                                    throws PortalException
        Generates embeddings for the given text.
        Parameters:
        text - the text.
        Returns:
        the embeddings.
        Throws:
        PortalException
        Since:
        16.1.0