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.SlingSafeMethodsServlet
Servlet providing various RAG supported services.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected com.google.gson.Gson
gson
static String
PARAM_EMBEDDINGORDER
Boolean parameter - if true, the results will be ordered by comparing the embedding with the query embedding.static String
PARAM_LIMIT
Maximum number of results from the search that are ranked with the embedding.static String
PARAM_LIMITRAGTEXTS
For query answering (ragAnswer): the maximum number of pages that are given to the AI to answer.static String
PARAM_PREPROCESS_QUERY
Boolean parameter - if true, the query will be preprocessed before searching to generate likely keywords.static String
PARAM_QUERY
The actual search query.protected RAGService
ragService
-
Constructor Summary
Constructors Constructor Description RAGServlet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doGet(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response)
protected String
ragAnswer(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.SlingSafeMethodsServlet
doGeneric, doHead, doOptions, doTrace, getAllowedRequestMethods, getServletInfo, handleMethodNotImplemented, mayService, service, service
-
-
-
-
Field Detail
-
gson
protected final com.google.gson.Gson gson
-
PARAM_QUERY
public static final String PARAM_QUERY
The actual search query.- See Also:
- Constant Field Values
-
PARAM_LIMIT
public 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_LIMITRAGTEXTS
public 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_EMBEDDINGORDER
public 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_QUERY
public static final String PARAM_PREPROCESS_QUERY
Boolean parameter - if true, the query will be preprocessed before searching to generate likely keywords.
-
ragService
protected RAGService ragService
-
-
Method Detail
-
doGet
protected void doGet(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response) throws javax.servlet.ServletException, IOException
- Overrides:
doGet
in classorg.apache.sling.api.servlets.SlingSafeMethodsServlet
- Throws:
javax.servlet.ServletException
IOException
-
related
protected 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
-
ragAnswer
protected 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
-
-