fixed issue where augumentation failed

This commit is contained in:
PaulKoudelka 2026-08-14 12:03:52 +02:00
parent 88999d985c
commit 50aa5c485d

View File

@ -44,10 +44,15 @@ public sealed class AugmentationOne : IAugmentationProcess
// Let's get the validation agent & set up its provider: // Let's get the validation agent & set up its provider:
var validationAgent = Program.SERVICE_PROVIDER.GetService<AgentRetrievalContextValidation>()!; var validationAgent = Program.SERVICE_PROVIDER.GetService<AgentRetrievalContextValidation>()!;
if (validationAgent.SetLLMProvider(provider, chatThread.DataSecurity, chatThread.DataConfidenceLevel)) if (validationAgent.SetLLMProvider(provider, chatThread.DataSecurity, chatThread.DataConfidenceLevel))
{
try
{ {
// Let's validate all retrieval contexts: // Let's validate all retrieval contexts:
var validationResults = await validationAgent.ValidateRetrievalContextsAsync(lastUserPrompt, chatThread, retrievalContexts, token); 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: // Now, filter the retrieval contexts to the most relevant ones:
// //
@ -57,11 +62,21 @@ public sealed class AugmentationOne : IAugmentationProcess
// Filter the retrieval contexts: // Filter the retrieval contexts:
retrievalContexts = validationResults.Where(x => x.RetrievalContext is not null && x.Confidence >= threshold).Select(x => x.RetrievalContext!).ToList(); 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 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: // We build a huge prompt from all retrieval contexts: