This commit is contained in:
2026-07-20 14:55:53 +02:00
parent b1279c5511
commit 74e7ea3dce
5 changed files with 30 additions and 6 deletions

View File

@@ -2,9 +2,11 @@ namespace AiResponseValidator.Core
{
/// <summary>
/// Backend-Optionen für einen Lauf. <see cref="NumCtx"/> steuert die
/// Kontextfenstergröße (Ollama <c>options.num_ctx</c>).
/// Kontextfenstergröße (Ollama <c>options.num_ctx</c>), <see cref="NumKeep"/> die
/// Anzahl der beim Kontextüberlauf vom Prompt-Anfang erhaltenen Tokens
/// (Ollama <c>options.num_keep</c>).
/// </summary>
public sealed record RunOptions(int? NumCtx = null, string CustomerId = null)
public sealed record RunOptions(int? NumCtx = null, int? NumKeep = null, string CustomerId = "response-validator")
{
public static readonly RunOptions Default = new RunOptions();
}

View File

@@ -90,8 +90,16 @@ namespace AiResponseValidator.Core.Runner
if (!string.IsNullOrEmpty(c.Options?.CustomerId))
payload["customerid"] = c.Options.CustomerId;
var options = new Dictionary<string, object>();
if (c.Options?.NumCtx is int ctx)
payload["options"] = new { num_ctx = ctx };
options["num_ctx"] = ctx;
if (c.Options?.NumKeep is int keep)
options["num_keep"] = keep;
if (options.Count > 0)
payload["options"] = options;
return payload;
}

View File

@@ -67,15 +67,20 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Margin="0,0,4,0">
<TextBlock Text="Wiederholungen" FontWeight="Bold" />
<TextBox Text="{Binding Repeat, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
<StackPanel Grid.Column="1" Margin="4,0,0,0">
<StackPanel Grid.Column="1" Margin="4,0,4,0">
<TextBlock Text="num_ctx (optional)" FontWeight="Bold" />
<TextBox Text="{Binding NumCtxText, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
<StackPanel Grid.Column="2" Margin="4,0,0,0">
<TextBlock Text="num_keep (optional)" FontWeight="Bold" />
<TextBox Text="{Binding NumKeepText, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</Grid>
</StackPanel>
</ScrollViewer>

View File

@@ -20,5 +20,6 @@ namespace AiResponseValidator
public string FillerText { get; set; }
public int Repeat { get; set; } = 1;
public string NumCtxText { get; set; }
public string NumKeepText { get; set; }
}
}

View File

@@ -35,6 +35,7 @@ namespace AiResponseValidator.ViewModels
private string _FillerText = "";
private int _Repeat = 1;
private string _NumCtxText = "";
private string _NumKeepText = "";
private string _StatusText = "Bereit.";
private CancellationTokenSource _Cts;
@@ -67,6 +68,7 @@ namespace AiResponseValidator.ViewModels
public string FillerText { get => _FillerText; set => Set(ref _FillerText, value); }
public int Repeat { get => _Repeat; set => Set(ref _Repeat, value); }
public string NumCtxText { get => _NumCtxText; set => Set(ref _NumCtxText, value); }
public string NumKeepText { get => _NumKeepText; set => Set(ref _NumKeepText, value); }
public string StatusText { get => _StatusText; set => Set(ref _StatusText, value); }
@@ -116,6 +118,7 @@ namespace AiResponseValidator.ViewModels
FillerText = s.FillerText ?? FillerText;
Repeat = s.Repeat > 0 ? s.Repeat : Repeat;
NumCtxText = s.NumCtxText ?? NumCtxText;
NumKeepText = s.NumKeepText ?? NumKeepText;
}
catch
{
@@ -141,7 +144,8 @@ namespace AiResponseValidator.ViewModels
SizesText = SizesText,
FillerText = FillerText,
Repeat = Repeat,
NumCtxText = NumCtxText
NumCtxText = NumCtxText,
NumKeepText = NumKeepText
};
var path = GetSettingsPath();
@@ -226,10 +230,14 @@ namespace AiResponseValidator.ViewModels
private TestPlan BuildPlan(IReadOnlyList<string> models)
{
int? num_ctx = null;
int? num_keep = null;
if (int.TryParse((NumCtxText ?? "").Trim(), out var ctx) && ctx > 0)
num_ctx = ctx;
if (int.TryParse((NumKeepText ?? "").Trim(), out var keep) && keep >= 0)
num_keep = keep;
var request = new RequestSpec("req1", RequestMessage, BuildRule());
return new TestPlan
@@ -237,7 +245,7 @@ namespace AiResponseValidator.ViewModels
SystemPrompt = SystemPrompt,
Requests = new[] { request },
Models = models,
Options = new RunOptions(num_ctx),
Options = new RunOptions(num_ctx, num_keep),
Repeat = Math.Max(1, Repeat)
};
}