From 50aa5c485d98a30320d35ba1d4aeda68f8d7230f Mon Sep 17 00:00:00 2001 From: PaulKoudelka Date: Fri, 14 Aug 2026 12:03:52 +0200 Subject: [PATCH] fixed issue where augumentation failed --- .../AugmentationProcesses/AugmentationOne.cs | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/app/MindWork AI Studio/Tools/RAG/AugmentationProcesses/AugmentationOne.cs b/app/MindWork AI Studio/Tools/RAG/AugmentationProcesses/AugmentationOne.cs index beac02c3..2c2a4171 100644 --- a/app/MindWork AI Studio/Tools/RAG/AugmentationProcesses/AugmentationOne.cs +++ b/app/MindWork AI Studio/Tools/RAG/AugmentationProcesses/AugmentationOne.cs @@ -45,23 +45,38 @@ public sealed class AugmentationOne : IAugmentationProcess var validationAgent = Program.SERVICE_PROVIDER.GetService()!; if (validationAgent.SetLLMProvider(provider, chatThread.DataSecurity, chatThread.DataConfidenceLevel)) { - // Let's validate all retrieval contexts: - var validationResults = await validationAgent.ValidateRetrievalContextsAsync(lastUserPrompt, chatThread, retrievalContexts, token); + try + { + // Let's validate all retrieval contexts: + var validationResults = await validationAgent.ValidateRetrievalContextsAsync(lastUserPrompt, chatThread, retrievalContexts, token); + if (validationResults.Count == 0) + LOGGER.LogWarning("Retrieval context validation returned no results. Continuing augmentation with all retrieved contexts."); + else + { + // + // Now, filter the retrieval contexts to the most relevant ones: + // + var targetWindow = validationResults.DetermineTargetWindow(TargetWindowStrategy.TOP10_BETTER_THAN_GUESSING); + var threshold = validationResults.GetConfidenceThreshold(targetWindow); - // - // Now, filter the retrieval contexts to the most relevant ones: - // - var targetWindow = validationResults.DetermineTargetWindow(TargetWindowStrategy.TOP10_BETTER_THAN_GUESSING); - var threshold = validationResults.GetConfidenceThreshold(targetWindow); - - // Filter the retrieval contexts: - retrievalContexts = validationResults.Where(x => x.RetrievalContext is not null && x.Confidence >= threshold).Select(x => x.RetrievalContext!).ToList(); + // Filter the retrieval contexts: + retrievalContexts = validationResults.Where(x => x.RetrievalContext is not null && x.Confidence >= threshold).Select(x => x.RetrievalContext!).ToList(); + } + } + catch (OperationCanceledException) when (token.IsCancellationRequested) + { + throw; + } + catch (Exception exception) + { + LOGGER.LogError(exception, "Retrieval context validation failed. Continuing augmentation with all retrieved contexts."); + } } else - LOGGER.LogWarning("Skipping retrieval context validation because no sufficiently trusted validation agent provider is available."); + LOGGER.LogWarning("Skipping retrieval context validation because no sufficiently trusted validation agent provider is available. Continuing augmentation with all retrieved contexts."); } - LOGGER.LogInformation($"Starting the augmentation process over {numTotalRetrievalContexts:###,###,###,###} retrieval contexts."); + LOGGER.LogInformation($"Starting the augmentation process over {retrievalContexts.Count:###,###,###,###} of {numTotalRetrievalContexts:###,###,###,###} retrieved contexts."); // // We build a huge prompt from all retrieval contexts: