Package sk.iway.iwcm.rag.search
Class RagService
java.lang.Object
sk.iway.iwcm.rag.search.RagService
Generates answers from retrieved chunks using a domain's configured or default RAG assistant.
Merges and limits context before supplying the question and source metadata to the AI service.
-
Constructor Summary
ConstructorsConstructorDescriptionRagService(AssistantDefinitionRepository assistantRepository, AiService aiService, AiStatRepository statRepo) -
Method Summary
Modifier and TypeMethodDescriptionanswerQuestion(String question, Integer domainId, List<VectorSearchResult> vectorChunkResults, jakarta.servlet.http.HttpServletRequest request) Generates an answer after merging and limiting authorized retrieval context.
-
Constructor Details
-
RagService
@Autowired public RagService(AssistantDefinitionRepository assistantRepository, AiService aiService, AiStatRepository statRepo)
-
-
Method Details
-
answerQuestion
public String answerQuestion(String question, Integer domainId, List<VectorSearchResult> vectorChunkResults, jakarta.servlet.http.HttpServletRequest request) Generates an answer after merging and limiting authorized retrieval context. Uses the component's selected assistant when available, otherwise creates or reuses the domain's default. Callers are responsible for authorizing the supplied chunks and sanitizing the returned answer for display.- Parameters:
question- user questiondomainId- domain owning the selected or default answer assistantvectorChunkResults- authorized chunks with retrieval scores and optional ranking and citation metadatarequest- request supplying component settings and AI provider context- Returns:
- trimmed assistant response, or
nullfor missing input, unavailable context or assistant, an empty or cannot-answer response, or a failed provider call
-