From 74e7ea3dce8de3e774b824b13ecb60dc0caa4cb0 Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Mon, 20 Jul 2026 14:55:53 +0200 Subject: [PATCH] num keep --- .../AiResponseValidator/Core/RunOptions.cs | 6 ++++-- .../Core/Runner/OllamaTestRunner.cs | 10 +++++++++- .../AiResponseValidator/MainWindow.xaml | 7 ++++++- .../AiResponseValidator/UserSettings.cs | 1 + .../AiResponseValidator/ViewModels/MainViewModel.cs | 12 ++++++++++-- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Tools/AiResponseValidator/AiResponseValidator/Core/RunOptions.cs b/Tools/AiResponseValidator/AiResponseValidator/Core/RunOptions.cs index 86ae96111..9b96e116d 100644 --- a/Tools/AiResponseValidator/AiResponseValidator/Core/RunOptions.cs +++ b/Tools/AiResponseValidator/AiResponseValidator/Core/RunOptions.cs @@ -2,9 +2,11 @@ namespace AiResponseValidator.Core { /// /// Backend-Optionen für einen Lauf. steuert die - /// Kontextfenstergröße (Ollama options.num_ctx). + /// Kontextfenstergröße (Ollama options.num_ctx), die + /// Anzahl der beim Kontextüberlauf vom Prompt-Anfang erhaltenen Tokens + /// (Ollama options.num_keep). /// - 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(); } diff --git a/Tools/AiResponseValidator/AiResponseValidator/Core/Runner/OllamaTestRunner.cs b/Tools/AiResponseValidator/AiResponseValidator/Core/Runner/OllamaTestRunner.cs index d62e65208..c570cfb3c 100644 --- a/Tools/AiResponseValidator/AiResponseValidator/Core/Runner/OllamaTestRunner.cs +++ b/Tools/AiResponseValidator/AiResponseValidator/Core/Runner/OllamaTestRunner.cs @@ -90,8 +90,16 @@ namespace AiResponseValidator.Core.Runner if (!string.IsNullOrEmpty(c.Options?.CustomerId)) payload["customerid"] = c.Options.CustomerId; + var options = new Dictionary(); + 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; } diff --git a/Tools/AiResponseValidator/AiResponseValidator/MainWindow.xaml b/Tools/AiResponseValidator/AiResponseValidator/MainWindow.xaml index 61f16ab80..b48ff734e 100644 --- a/Tools/AiResponseValidator/AiResponseValidator/MainWindow.xaml +++ b/Tools/AiResponseValidator/AiResponseValidator/MainWindow.xaml @@ -67,15 +67,20 @@ + - + + + + + diff --git a/Tools/AiResponseValidator/AiResponseValidator/UserSettings.cs b/Tools/AiResponseValidator/AiResponseValidator/UserSettings.cs index 97d586b6e..4912f69a5 100644 --- a/Tools/AiResponseValidator/AiResponseValidator/UserSettings.cs +++ b/Tools/AiResponseValidator/AiResponseValidator/UserSettings.cs @@ -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; } } } diff --git a/Tools/AiResponseValidator/AiResponseValidator/ViewModels/MainViewModel.cs b/Tools/AiResponseValidator/AiResponseValidator/ViewModels/MainViewModel.cs index 4f6ce18fc..264f6c6f8 100644 --- a/Tools/AiResponseValidator/AiResponseValidator/ViewModels/MainViewModel.cs +++ b/Tools/AiResponseValidator/AiResponseValidator/ViewModels/MainViewModel.cs @@ -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 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) }; }