AI-Studio/app/MindWork AI Studio/Models/ModelProfileChange.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

84 lines
3.2 KiB
C#

using AIStudio.Provider;
namespace AIStudio.Models;
/// <summary>
/// What a rule states about a model, as a change to what is known so far.
/// </summary>
/// <remarks>
/// A selector applies its change to nothing and so states a whole profile; a modifier applies its
/// change to whatever the selector decided. One type for both, because "adds web search" and "takes
/// web search away again" are the same kind of sentence.
///
/// Everything left unsaid stays as it was. That is what lets a rule for a variant say only what
/// makes the variant different, instead of repeating the family it belongs to.
/// </remarks>
public sealed record ModelProfileChange
{
/// <summary>
/// A change which states nothing.
/// </summary>
public static readonly ModelProfileChange NOTHING = new();
/// <summary>
/// Capabilities the model has.
/// </summary>
public Capability Adds { get; init; }
/// <summary>
/// Capabilities the model does not have, applied after the ones it has.
/// </summary>
public Capability Removes { get; init; }
/// <summary>
/// How the model reasons, or null to leave that as it was.
/// </summary>
public ReasoningSupport? Reasoning { get; init; }
/// <summary>
/// What the model is made for, or null to leave that as it was.
/// </summary>
public ModelKind? Kind { get; init; }
/// <summary>
/// The context window, or null to leave it as it was.
/// </summary>
public ContextWindow? Context { get; init; }
/// <summary>
/// The tokenizer reference, or null to leave it as it was.
/// </summary>
public TokenizerRef? Tokenizer { get; init; }
/// <summary>
/// The image limits, or null to leave them as they were.
/// </summary>
public ImageLimits? Images { get; init; }
/// <summary>
/// Applies this change to a profile.
/// </summary>
/// <remarks>
/// The three reasoning members of the capability enum are dropped here rather than trusted to
/// stay out: they are the vocabulary a person writes an override in, and a profile which
/// carried them could say that a model both always reasons and reasons on request. A rule which
/// declares one has still made a mistake, which is why the tests and the verification run look
/// for it instead of relying on this line to hide it.
///
/// Every member of a profile is named below, so the copy could be written as a new profile
/// instead. It stays a copy on purpose: the day a profile learns something this change does not
/// know about yet, a modifier has to hand that on rather than reset it to nothing.
/// </remarks>
/// <param name="profile">What is known so far.</param>
/// <returns>What is known afterward.</returns>
// ReSharper disable once WithExpressionModifiesAllMembers
public ModelProfile ApplyTo(in ModelProfile profile) => profile with
{
Capabilities = (profile.Capabilities | this.Adds) & ~this.Removes & ~ModelProfile.REASONING_VOCABULARY,
Reasoning = this.Reasoning ?? profile.Reasoning,
Kind = this.Kind ?? profile.Kind,
Context = this.Context ?? profile.Context,
Tokenizer = this.Tokenizer ?? profile.Tokenizer,
Images = this.Images ?? profile.Images,
};
}