diff --git a/app/MindWork AI Studio/Agents/AgentRetrievalContextValidation.cs b/app/MindWork AI Studio/Agents/AgentRetrievalContextValidation.cs index 7dd226f2..c197eb84 100644 --- a/app/MindWork AI Studio/Agents/AgentRetrievalContextValidation.cs +++ b/app/MindWork AI Studio/Agents/AgentRetrievalContextValidation.cs @@ -121,12 +121,16 @@ public sealed class AgentRetrievalContextValidation (ILogger ValidateRetrievalContextAsync(IProvider provider, IContent lastPrompt, ChatThread chatThread, IRetrievalContext dataContext, CancellationToken token = default) + /// + /// Sets the LLM provider for the agent. + /// + /// + /// When you have to call the validation in parallel for many retrieval contexts, + /// you can set the provider once and then call the validation method in parallel. + /// + /// The current LLM provider. When the user doesn't preselect an agent provider, the agent uses this provider. + public void SetLLMProvider(IProvider provider) { - // - // 1. Which LLM provider should the agent use? - // - // We start with the provider currently selected by the user: var agentProvider = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == provider.Id); @@ -143,9 +147,24 @@ public sealed class AgentRetrievalContextValidation (ILogger + /// Validates the retrieval context against the last user and the system prompt. + /// + /// + /// Probably, you have a lot of retrieval contexts to validate. In this case, you + /// can call this method in parallel for each retrieval context. + /// + /// The last user prompt. + /// The chat thread. + /// The retrieval context to validate. + /// The cancellation token. + /// The validation result. + public async Task ValidateRetrievalContextAsync(IContent lastPrompt, ChatThread chatThread, IRetrievalContext dataContext, CancellationToken token = default) + { // - // 2. Prepare the current system and user prompts as input for the agent: + // 1. Prepare the current system and user prompts as input for the agent: // var lastPromptContent = lastPrompt switch { @@ -165,14 +184,14 @@ public sealed class AgentRetrievalContextValidation (ILogger(); var markdownRetrievalContext = await dataContext.AsMarkdown(token: token); additionalData.Add("retrievalContext", markdownRetrievalContext); // - // 4. Let the agent validate the retrieval context: + // 3. Let the agent validate the retrieval context: // var prompt = $""" The system prompt is: @@ -210,7 +229,7 @@ public sealed class AgentRetrievalContextValidation (ILogger