mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-09-24 11:13:36 +00:00
Some checks are pending
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Verify (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
55 lines
2.3 KiB
C#
55 lines
2.3 KiB
C#
using AIStudio.Tools.ToolCallingSystem;
|
|
|
|
namespace AIStudio.Tests.Tools.ToolCalling;
|
|
|
|
/// <summary>
|
|
/// Checks how a selection of tools turns into the set which actually runs.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Every tool selection in the app passes through this, and so do the audit of an assistant plugin
|
|
/// and its security card. Whatever it adds is therefore what the user and the audit get to see, so it
|
|
/// must neither add a tool nobody asked for nor keep adding each time it runs.
|
|
/// </remarks>
|
|
[TestFixture]
|
|
public sealed class ToolSelectionRulesTests
|
|
{
|
|
private const string SEARCH_CONFLUENCE = ToolSelectionRules.SEARCH_CONFLUENCE_TOOL_ID;
|
|
private const string READ_WEB_PAGE = ToolSelectionRules.READ_WEB_PAGE_TOOL_ID;
|
|
private const string WEB_SEARCH = ToolSelectionRules.WEB_SEARCH_TOOL_ID;
|
|
|
|
[Test]
|
|
public void SearchConfluenceBringsReadWebPageAlong()
|
|
{
|
|
Assert.That(ToolSelectionRules.NormalizeSelection([SEARCH_CONFLUENCE]), Is.EquivalentTo(new[] { SEARCH_CONFLUENCE, READ_WEB_PAGE }), "The search only finds pages; without Read Web Page the model could not open a single result.");
|
|
}
|
|
|
|
[TestCase(READ_WEB_PAGE)]
|
|
[TestCase(WEB_SEARCH)]
|
|
public void OtherToolsBringNothingAlong(string toolId)
|
|
{
|
|
Assert.That(ToolSelectionRules.NormalizeSelection([toolId]), Is.EquivalentTo(new[] { toolId }), "Only Search Confluence depends on another tool. Read Web Page in particular does not pull the search in.");
|
|
}
|
|
|
|
[Test]
|
|
public void NormalizingTwiceChangesNothing()
|
|
{
|
|
var once = ToolSelectionRules.NormalizeSelection([SEARCH_CONFLUENCE, WEB_SEARCH]);
|
|
|
|
Assert.That(ToolSelectionRules.NormalizeSelection(once), Is.EquivalentTo(once), "The selection fields normalize whatever they receive, including a selection they normalized themselves a moment ago.");
|
|
}
|
|
|
|
[Test]
|
|
public void ATwiceSelectedToolRunsOnce()
|
|
{
|
|
Assert.That(ToolSelectionRules.NormalizeSelection([WEB_SEARCH, WEB_SEARCH]), Has.Count.EqualTo(1));
|
|
}
|
|
|
|
[Test]
|
|
public void TheSelectionPassedInStaysUntouched()
|
|
{
|
|
HashSet<string> selected = [SEARCH_CONFLUENCE];
|
|
ToolSelectionRules.NormalizeSelection(selected);
|
|
|
|
Assert.That(selected, Is.EquivalentTo(new[] { SEARCH_CONFLUENCE }), "The caller's set, such as the tools of a stored chat template, must not change behind its back.");
|
|
}
|
|
} |