Interface ApproximateMarkdownService

  • All Known Implementing Classes:
    ApproximateMarkdownServiceImpl

    public interface ApproximateMarkdownService
    A service to create markdown with an approximate text content from a page or resource, for use with querying the AI about it.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String HEADER_IMAGEPATH
      An additional header for the response that tells that the path is actually an image and gives its path.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void approximateMarkdown​(org.apache.sling.api.resource.Resource resource, PrintWriter out, org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response)
      Generates a text formatted with markdown that heuristically represents the text content of a page or resource, mainly for use with the AI.
      String approximateMarkdown​(org.apache.sling.api.resource.Resource resource, org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response)
      Generates a text formatted with markdown that heuristically represents the text content of a page or resource, mainly for use with the AI.
      List<ApproximateMarkdownService.Link> getComponentLinks​(org.apache.sling.api.resource.Resource resource)
      Returns a number of links that are saved in the component or siblings of the component that could be used as a proposal for the user to be used as source for the AI via markdown generation etc.
      String getImageUrl​(org.apache.sling.api.resource.Resource imageResource)
      Retrieves the imageURL in a way useable for ChatGPT - usually data:image/jpeg;base64,{base64_image}
      String getMarkdown​(String value)
      Returns a markdown representation of an attribute value, which might be plain text or HTML.
      String getMarkdown​(URI uri)
      Retrieves the text content for an URL.
    • Field Detail

      • HEADER_IMAGEPATH

        static final String HEADER_IMAGEPATH
        An additional header for the response that tells that the path is actually an image and gives its path.
        See Also:
        Constant Field Values
    • Method Detail

      • approximateMarkdown

        @Nonnull
        String approximateMarkdown​(@Nullable
                                   org.apache.sling.api.resource.Resource resource,
                                   @Nonnull
                                   org.apache.sling.api.SlingHttpServletRequest request,
                                   @Nonnull
                                   org.apache.sling.api.SlingHttpServletResponse response)
        Generates a text formatted with markdown that heuristically represents the text content of a page or resource, mainly for use with the AI. That is rather heuristically - it cannot faithfully represent the page, but will probably be enough to generate summaries, keywords and so forth.
        Parameters:
        resource - the resource to render to markdown. Caution: if this is not the content resource of a page but the cpp:Page, the markdown will contain all subpages as well!
        request -
        response -
        Returns:
        the markdown representation
      • approximateMarkdown

        void approximateMarkdown​(@Nullable
                                 org.apache.sling.api.resource.Resource resource,
                                 @Nonnull
                                 PrintWriter out,
                                 @Nonnull
                                 org.apache.sling.api.SlingHttpServletRequest request,
                                 @Nonnull
                                 org.apache.sling.api.SlingHttpServletResponse response)
        Generates a text formatted with markdown that heuristically represents the text content of a page or resource, mainly for use with the AI. That is rather heuristically - it cannot faithfully represent the page, but will probably be enough to generate summaries, keywords and so forth.
        Parameters:
        resource - the resource to render to markdown. Caution: if this is not the content resource of a page but the cpp:Page, the markdown will contain all subpages as well!
        out - destination where the markdown rendering will be written.
        request -
        response -
      • getMarkdown

        @Nonnull
        String getMarkdown​(@Nullable
                           String value)
        Returns a markdown representation of an attribute value, which might be plain text or HTML. We determine whether it's HTML heuristically - in that case it's transformed to markdown, otherwise we just return the value.
      • getComponentLinks

        @Nonnull
        List<ApproximateMarkdownService.Link> getComponentLinks​(@Nullable
                                                                org.apache.sling.api.resource.Resource resource)
        Returns a number of links that are saved in the component or siblings of the component that could be used as a proposal for the user to be used as source for the AI via markdown generation etc. This heuristically collects a number of links that might be interesting.
        Parameters:
        resource - the resource to check
        Returns:
        a list of links, or an empty list if there are none.
      • getImageUrl

        @Nullable
        String getImageUrl​(@Nullable
                           org.apache.sling.api.resource.Resource imageResource)
        Retrieves the imageURL in a way useable for ChatGPT - usually data:image/jpeg;base64,{base64_image}