AI-Studio/app/Tests/Models/ModelFactsTests.cs
Thorsten Sommer d85b4e71b6
Some checks are pending
Build and Release / Determine run mode (push) Waiting to run
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
Rebuilt how AI Studio knows what a model can do (#960)
2026-09-13 14:17:25 +02:00

101 lines
3.1 KiB
C#

using AIStudio.Models;
namespace AIStudio.Tests.Models;
/// <summary>
/// Checks the three types which have to be able to say "nobody knows".
/// </summary>
/// <remarks>
/// They are tested together because they are tested for the same thing. Each of them is a value
/// type sitting inside a model profile, so each of them has a default value somebody will read
/// before anything was written into it, and that default has to mean unknown rather than zero. The
/// day one of them answers "a context window of zero tokens" instead, a feature built on top of it
/// will quietly do the wrong thing.
/// </remarks>
[TestFixture]
public sealed class ModelFactsTests
{
[Test]
public void AContextWindowNobodyWroteDownIsUnknown()
{
ContextWindow untouched = default;
Assert.Multiple(() =>
{
Assert.That(untouched.IsKnown, Is.False);
Assert.That(untouched, Is.EqualTo(ContextWindow.UNKNOWN));
});
}
[Test]
public void AContextWindowStatesWhatItShipsWithAndWhatItCanBeRaisedTo()
{
var window = ContextWindow.Of(128_000, 1_000_000);
Assert.Multiple(() =>
{
Assert.That(window.IsKnown, Is.True);
Assert.That(window.DefaultTokens, Is.EqualTo(128_000));
Assert.That(window.RaisableToTokens, Is.EqualTo(1_000_000));
});
}
[Test]
public void AContextWindowWhichCannotBeRaisedSaysSoWithNothingRatherThanWithItsOwnSize()
{
var window = ContextWindow.Of(32_768);
Assert.That(window.RaisableToTokens, Is.Null);
}
[Test]
public void AContextWindowOfNoTokensCannotBeStated() => Assert.Throws<ArgumentOutOfRangeException>(() => ContextWindow.Of(0));
[Test]
public void AContextWindowCannotBeRaisedToLessThanItAlreadyIs() => Assert.Throws<ArgumentOutOfRangeException>(() => ContextWindow.Of(128_000, 32_768));
[Test]
public void ATokenizerNobodyWroteDownIsTheBuiltInOne()
{
TokenizerRef untouched = default;
Assert.Multiple(() =>
{
Assert.That(untouched.IsKnown, Is.False);
Assert.That(untouched.Kind, Is.EqualTo(TokenizerKind.UNKNOWN));
});
}
[Test]
public void ATokenizerWithoutANameIsNotKnownEvenWhenItsKindIs()
{
var nameless = new TokenizerRef(TokenizerKind.HUGGING_FACE, string.Empty);
Assert.That(nameless.IsKnown, Is.False);
}
[Test]
public void ImageLimitsNobodyWroteDownAreUnknown()
{
ImageLimits untouched = default;
Assert.Multiple(() =>
{
Assert.That(untouched.IsKnown, Is.False);
Assert.That(untouched.MaxPerMessage, Is.Null);
Assert.That(untouched.MaxPerRequest, Is.Null);
});
}
[Test]
public void ImageLimitsTellNoImagesApartFromNobodyHavingSaid()
{
var noImages = new ImageLimits(MaxPerMessage: 0, MaxPerRequest: null);
Assert.Multiple(() =>
{
Assert.That(noImages.IsKnown, Is.True, "Zero images is a statement an operator can make.");
Assert.That(noImages.MaxPerMessage, Is.EqualTo(0));
});
}
}