Class RAGServlet
- java.lang.Object
- 
- javax.servlet.GenericServlet
- 
- org.apache.sling.api.servlets.SlingSafeMethodsServlet
- 
- com.composum.ai.backend.slingbase.impl.RAGServlet
 
 
 
- 
- All Implemented Interfaces:
- Serializable,- javax.servlet.Servlet,- javax.servlet.ServletConfig
 
 public class RAGServlet extends org.apache.sling.api.servlets.SlingSafeMethodsServletServlet providing various RAG supported services.- See Also:
- Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected com.google.gson.Gsongsonstatic StringPARAM_EMBEDDINGORDERBoolean parameter - if true, the results will be ordered by comparing the embedding with the query embedding.static StringPARAM_LIMITMaximum number of results from the search that are ranked with the embedding.static StringPARAM_LIMITRAGTEXTSFor query answering (ragAnswer): the maximum number of pages that are given to the AI to answer.static StringPARAM_PREPROCESS_QUERYBoolean parameter - if true, the query will be preprocessed before searching to generate likely keywords.static StringPARAM_QUERYThe actual search query.protected RAGServiceragService
 - 
Constructor SummaryConstructors Constructor Description RAGServlet()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoGet(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response)protected StringragAnswer(org.apache.sling.api.resource.ResourceResolver resourceResolver, org.apache.sling.api.resource.Resource searchRoot, String query, int limit, boolean embeddingOrder, org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, int limitRagTexts, boolean preprocessQuery)protected List<?>related(org.apache.sling.api.resource.ResourceResolver resourceResolver, org.apache.sling.api.resource.Resource searchRoot, String query, int limit, boolean embeddingOrder, org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, boolean preprocessQuery)Does a plain search for the terms, without actual RAG.- 
Methods inherited from class org.apache.sling.api.servlets.SlingSafeMethodsServletdoGeneric, doHead, doOptions, doTrace, getAllowedRequestMethods, getServletInfo, handleMethodNotImplemented, mayService, service, service
 
- 
 
- 
- 
- 
Field Detail- 
gsonprotected final com.google.gson.Gson gson 
 - 
PARAM_QUERYpublic static final String PARAM_QUERY The actual search query.- See Also:
- Constant Field Values
 
 - 
PARAM_LIMITpublic static final String PARAM_LIMIT Maximum number of results from the search that are ranked with the embedding. Default is 20.- See Also:
- Constant Field Values
 
 - 
PARAM_LIMITRAGTEXTSpublic static final String PARAM_LIMITRAGTEXTS For query answering (ragAnswer): the maximum number of pages that are given to the AI to answer. Default is 5.- See Also:
- Constant Field Values
 
 - 
PARAM_EMBEDDINGORDERpublic static final String PARAM_EMBEDDINGORDER Boolean parameter - if true, the results will be ordered by comparing the embedding with the query embedding.- See Also:
- Constant Field Values
 
 - 
PARAM_PREPROCESS_QUERYpublic static final String PARAM_PREPROCESS_QUERY Boolean parameter - if true, the query will be preprocessed before searching to generate likely keywords.
 - 
ragServiceprotected RAGService ragService 
 
- 
 - 
Method Detail- 
doGetprotected void doGet(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response) throws javax.servlet.ServletException, IOException- Overrides:
- doGetin class- org.apache.sling.api.servlets.SlingSafeMethodsServlet
- Throws:
- javax.servlet.ServletException
- IOException
 
 - 
relatedprotected List<?> related(@Nonnull org.apache.sling.api.resource.ResourceResolver resourceResolver, @Nonnull org.apache.sling.api.resource.Resource searchRoot, @Nonnull String query, int limit, boolean embeddingOrder, org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, boolean preprocessQuery) throws javax.jcr.RepositoryException Does a plain search for the terms, without actual RAG. E.g. http://localhost:9090/bin/cpm/ai/rag.related.json/content/ist/composum/home?query=AI- Throws:
- javax.jcr.RepositoryException
 
 - 
ragAnswerprotected String ragAnswer(@Nonnull org.apache.sling.api.resource.ResourceResolver resourceResolver, @Nonnull org.apache.sling.api.resource.Resource searchRoot, @Nonnull String query, int limit, boolean embeddingOrder, org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, int limitRagTexts, boolean preprocessQuery) throws javax.jcr.RepositoryException - Throws:
- javax.jcr.RepositoryException
 
 
- 
 
-