mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-12-06 04:31:36 +00:00
Renamed the settings of AI tasks (#1239)
This commit is contained in:
1 parent
d19d3d431b
commit
a117074972
109 files changed
+3929
-538
No files matched your search
@@ -0,0 +1,75 @@
|
||||
using AIStudio.Provider;
|
||||
using AIStudio.Settings;
|
||||
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
|
||||
namespace AIStudio.Tests.Settings;
|
||||
|
||||
/// <summary>
|
||||
/// Checks when the minimum confidence of an AI task applies.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The text content cleaner, the data source selection, and the retrieval context validation apply their
|
||||
/// provider and their minimum only while their preselection is switched on, like the assistants. The audit
|
||||
/// of plugins has no such switch, so its minimum always applies. Names are written out in full where a short
|
||||
/// one would find a namespace of this assembly first, see AIOperationProviderResolverTests.
|
||||
/// </remarks>
|
||||
[TestFixture]
|
||||
public sealed class AITaskMinimumConfidenceTests
|
||||
{
|
||||
[Test]
|
||||
public void TheTextContentCleanerAppliesItsMinimumOnlyWithItsPreselection()
|
||||
{
|
||||
var settingsManager = CreateSettingsManager();
|
||||
settingsManager.ConfigurationData.TextContentCleaner.MinimumProviderConfidence = ConfidenceLevel.HIGH;
|
||||
|
||||
AssertMinimumFollowsPreselection(settingsManager, AIStudio.Tools.Components.AI_TASK_TEXT_CONTENT_CLEANER, on => settingsManager.ConfigurationData.TextContentCleaner.PreselectOptions = on);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheDataSourceSelectionAppliesItsMinimumOnlyWithItsPreselection()
|
||||
{
|
||||
var settingsManager = CreateSettingsManager();
|
||||
settingsManager.ConfigurationData.DataSourceSelection.MinimumProviderConfidence = ConfidenceLevel.HIGH;
|
||||
|
||||
AssertMinimumFollowsPreselection(settingsManager, AIStudio.Tools.Components.AI_TASK_DATA_SOURCE_SELECTION, on => settingsManager.ConfigurationData.DataSourceSelection.PreselectOptions = on);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheRetrievalContextValidationAppliesItsMinimumOnlyWithItsPreselection()
|
||||
{
|
||||
var settingsManager = CreateSettingsManager();
|
||||
settingsManager.ConfigurationData.RetrievalContextValidation.MinimumProviderConfidence = ConfidenceLevel.HIGH;
|
||||
|
||||
AssertMinimumFollowsPreselection(settingsManager, AIStudio.Tools.Components.AI_TASK_RETRIEVAL_CONTEXT_VALIDATION, on => settingsManager.ConfigurationData.RetrievalContextValidation.PreselectOptions = on);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ThePluginAuditAlwaysAppliesItsMinimum()
|
||||
{
|
||||
var settingsManager = CreateSettingsManager();
|
||||
settingsManager.ConfigurationData.AssistantPluginAudit.MinimumProviderConfidence = ConfidenceLevel.HIGH;
|
||||
|
||||
Assert.That(AIStudio.Tools.ComponentsExtensions.MinimumConfidence(AIStudio.Tools.Components.AI_TASK_ASSISTANT_PLUGIN_AUDIT, settingsManager), Is.EqualTo(ConfidenceLevel.HIGH), "The audit has no preselection switch, so nothing may turn its minimum off.");
|
||||
}
|
||||
|
||||
private static void AssertMinimumFollowsPreselection(SettingsManager settingsManager, AIStudio.Tools.Components component, Action<bool> setPreselection)
|
||||
{
|
||||
setPreselection(false);
|
||||
var minimumWithoutPreselection = AIStudio.Tools.ComponentsExtensions.MinimumConfidence(component, settingsManager);
|
||||
|
||||
setPreselection(true);
|
||||
var minimumWithPreselection = AIStudio.Tools.ComponentsExtensions.MinimumConfidence(component, settingsManager);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(minimumWithoutPreselection, Is.EqualTo(ConfidenceLevel.NONE), "With the preselection switched off, the stored minimum must not apply.");
|
||||
Assert.That(minimumWithPreselection, Is.EqualTo(ConfidenceLevel.HIGH));
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds a settings manager without the rust service, which reading a minimum never asks.
|
||||
/// </summary>
|
||||
private static SettingsManager CreateSettingsManager() => new(NullLogger<SettingsManager>.Instance, null!);
|
||||
}
|
||||
Reference in new issue
Block a user