mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-08 14:49:40 +00:00
Add the model limits to the expert settings
This commit is contained in:
6 files changed
+251
-2
No files matched your search
@@ -242,6 +242,64 @@
|
||||
</MudSelect>
|
||||
</MudPaper>
|
||||
</MudStack>
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2">
|
||||
@T("Override Model Limits")
|
||||
</MudText>
|
||||
<MudJustifiedText Typo="Typo.body2" Class="mb-4">
|
||||
@T("Where the stored numbers do not match your installation, state yours here. This matters most for self-hosted models: they run with whatever their operator configured, which the model card cannot know.")
|
||||
</MudJustifiedText>
|
||||
<MudStack Class="mb-4" Spacing="2">
|
||||
<MudPaper Outlined="@true" Class="pa-3">
|
||||
<MudNumericField T="int?"
|
||||
Value="@this.capabilityOverrides.ContextWindowTokens"
|
||||
ValueChanged="@this.SetContextWindowOverride"
|
||||
Label="@T("Context window in tokens")"
|
||||
HelperText="@this.ContextWindowHelperText"
|
||||
Placeholder="@this.AutomaticContextWindowPlaceholder"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense"
|
||||
Min="1"
|
||||
HideSpinButtons="@true"
|
||||
Clearable="@true"
|
||||
Disabled="@this.IsEnterpriseConfiguration"
|
||||
Adornment="Adornment.Start"
|
||||
AdornmentIcon="@Icons.Material.Filled.Straighten"
|
||||
AdornmentColor="Color.Info" />
|
||||
</MudPaper>
|
||||
<MudPaper Outlined="@true" Class="pa-3">
|
||||
<MudText Typo="Typo.body2">
|
||||
@T("Images")
|
||||
</MudText>
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">
|
||||
@this.ImageLimitsEffectiveLabel
|
||||
</MudText>
|
||||
<MudStack Row="@true" Spacing="3" Wrap="Wrap.Wrap" Class="border-dashed border rounded-lg pa-3 mt-3">
|
||||
<MudNumericField T="int?"
|
||||
Value="@this.capabilityOverrides.MaxImagesPerMessage"
|
||||
ValueChanged="@this.SetMaxImagesPerMessageOverride"
|
||||
Label="@T("Per message")"
|
||||
Placeholder="@this.AutomaticImageLimitPlaceholder(this.GetAutomaticModelProfile().Images.MaxPerMessage)"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense"
|
||||
Min="0"
|
||||
Clearable="@true"
|
||||
Disabled="@this.IsEnterpriseConfiguration" />
|
||||
<MudNumericField T="int?"
|
||||
Value="@this.capabilityOverrides.MaxImagesPerRequest"
|
||||
ValueChanged="@this.SetMaxImagesPerRequestOverride"
|
||||
Label="@T("Per request")"
|
||||
Placeholder="@this.AutomaticImageLimitPlaceholder(this.GetAutomaticModelProfile().Images.MaxPerRequest)"
|
||||
Variant="Variant.Outlined"
|
||||
Margin="Margin.Dense"
|
||||
Min="0"
|
||||
Clearable="@true"
|
||||
Disabled="@this.IsEnterpriseConfiguration" />
|
||||
</MudStack>
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary" Class="mt-2">
|
||||
@T("Vendors state one of the two, the other, or neither. Whichever is smaller decides how many images one message may carry; an empty field states nothing.")
|
||||
</MudText>
|
||||
</MudPaper>
|
||||
</MudStack>
|
||||
<MudJustifiedText Typo="Typo.body2" Class="mb-4">
|
||||
@string.Format(T("The current model uses the {0}."), this.GetCurrentModelApiLabel())
|
||||
</MudJustifiedText>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
@@ -164,6 +165,16 @@ public partial class ProviderDialog : MSGComponentBase, ISecretId
|
||||
private bool usesLegacySystemModelFallback;
|
||||
private bool showExpertSettings;
|
||||
private ProviderCapabilityOverrides capabilityOverrides = new();
|
||||
|
||||
/// <summary>
|
||||
/// The culture the numbers of this dialog are written in.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// AI Studio's language is a setting of its own and does not move the thread's culture along
|
||||
/// with it. Without this, a German who chose German would read a context window of 131,072
|
||||
/// tokens as a number a thousand times smaller.
|
||||
/// </remarks>
|
||||
private CultureInfo currentCulture = CultureInfo.InvariantCulture;
|
||||
|
||||
// We get the form reference from Blazor code to validate it manually:
|
||||
private MudForm form = null!;
|
||||
@@ -227,7 +238,11 @@ public partial class ProviderDialog : MSGComponentBase, ISecretId
|
||||
{
|
||||
// Call the base initialization first so that the I18N is ready:
|
||||
await base.OnInitializedAsync();
|
||||
|
||||
|
||||
// The numbers of the expert settings are written the way the chosen language writes them:
|
||||
var activeLanguagePlugin = await this.SettingsManager.GetActiveLanguagePlugin();
|
||||
this.currentCulture = CommonTools.DeriveActiveCultureOrInvariant(activeLanguagePlugin.IETFTag);
|
||||
|
||||
// Configure the spellchecking for the instance name input:
|
||||
this.SettingsManager.InjectSpellchecking(SPELLCHECK_ATTRIBUTES);
|
||||
|
||||
@@ -754,6 +769,83 @@ public partial class ProviderDialog : MSGComponentBase, ISecretId
|
||||
return isEnabled ? T("Enabled (Auto)") : T("Disabled (Auto)");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// States how many tokens this installation reads and writes.
|
||||
/// </summary>
|
||||
/// <param name="tokens">The number of tokens, or null to go back to the automatic answer.</param>
|
||||
private void SetContextWindowOverride(int? tokens) => this.capabilityOverrides = this.capabilityOverrides with { ContextWindowTokens = tokens };
|
||||
|
||||
/// <summary>
|
||||
/// States how many images one message may carry here.
|
||||
/// </summary>
|
||||
/// <param name="images">The number of images, or null to go back to the automatic answer.</param>
|
||||
private void SetMaxImagesPerMessageOverride(int? images) => this.capabilityOverrides = this.capabilityOverrides with { MaxImagesPerMessage = images };
|
||||
|
||||
/// <summary>
|
||||
/// States how many images one request may carry here.
|
||||
/// </summary>
|
||||
/// <param name="images">The number of images, or null to go back to the automatic answer.</param>
|
||||
private void SetMaxImagesPerRequestOverride(int? images) => this.capabilityOverrides = this.capabilityOverrides with { MaxImagesPerRequest = images };
|
||||
|
||||
/// <summary>
|
||||
/// What an empty window field shows.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Written without separators, unlike the number in the helper text next to it: this one stands
|
||||
/// inside the field a person types into, and what they see there has to be what they may type.
|
||||
/// </remarks>
|
||||
private string AutomaticContextWindowPlaceholder
|
||||
{
|
||||
get
|
||||
{
|
||||
var context = this.GetAutomaticModelProfile().Context;
|
||||
return context.IsKnown ? context.DefaultTokens.ToString(CultureInfo.InvariantCulture) : string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// What an empty image field shows.
|
||||
/// </summary>
|
||||
/// <param name="limit">The limit the rules worked out, if any.</param>
|
||||
/// <returns>The number, or nothing where nobody stated one.</returns>
|
||||
private string AutomaticImageLimitPlaceholder(int? limit) => limit?.ToString(CultureInfo.InvariantCulture) ?? string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// What the window field says below itself.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// It names the automatic answer rather than the one in effect, because the number in effect is
|
||||
/// already in the field. What a person cannot otherwise see is what they would go back to.
|
||||
/// </remarks>
|
||||
private string ContextWindowHelperText
|
||||
{
|
||||
get
|
||||
{
|
||||
var context = this.GetAutomaticModelProfile().Context;
|
||||
return context.IsKnown
|
||||
? string.Format(T("Detected: {0} tokens. Leave the field empty to use that."), context.DefaultTokens.ToString("N0", this.currentCulture))
|
||||
: T("Nobody has stated a window for this model. Left empty, the chat counts the tokens of a conversation without saying what they may grow to.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// What the two image fields say above themselves.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The number in effect, not the two the person typed: which of them decides is the one thing
|
||||
/// two fields cannot show on their own, and it is the one the chat and the Visual Briefing go by.
|
||||
/// </remarks>
|
||||
private string ImageLimitsEffectiveLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
var allowed = this.GetCurrentModelProfile().Images.MaxInOneMessage;
|
||||
return allowed is { } count
|
||||
? string.Format(T("At most {0} images at once."), count.ToString("N0", this.currentCulture))
|
||||
: T("No limit known, so AI Studio does not stop anybody from attaching more.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// What the model can do as this provider instance is configured, the person's own settings included.
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user