From d2c1841853be6e5fe322f83cf93dec23bbd215a7 Mon Sep 17 00:00:00 2001 From: Nick Beckley Date: Sat, 4 Jul 2026 19:34:15 +0100 Subject: [PATCH] Phase 20J Fix --- PlotLine/Models/StoryIntelligenceModels.cs | 1 - .../StoryIntelligenceOpenAIInfrastructure.cs | 24 +++++++++++++------ .../ViewModels/FeatureRequestViewModels.cs | 1 - .../Admin/StoryIntelligenceDiagnostics.cshtml | 8 +++---- .../Views/Admin/StoryIntelligenceTest.cshtml | 4 ++-- PlotLine/appsettings.json | 1 - 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/PlotLine/Models/StoryIntelligenceModels.cs b/PlotLine/Models/StoryIntelligenceModels.cs index 0a466c1..4344e8c 100644 --- a/PlotLine/Models/StoryIntelligenceModels.cs +++ b/PlotLine/Models/StoryIntelligenceModels.cs @@ -69,7 +69,6 @@ public sealed class StoryIntelligenceOptions { public string ApiKey { get; init; } = string.Empty; public string Model { get; init; } = string.Empty; - public decimal Temperature { get; init; } = 0.2m; public int MaxOutputTokens { get; init; } = 4000; public int TimeoutSeconds { get; init; } = 120; } diff --git a/PlotLine/Services/StoryIntelligenceOpenAIInfrastructure.cs b/PlotLine/Services/StoryIntelligenceOpenAIInfrastructure.cs index 2d1f575..26b4b7d 100644 --- a/PlotLine/Services/StoryIntelligenceOpenAIInfrastructure.cs +++ b/PlotLine/Services/StoryIntelligenceOpenAIInfrastructure.cs @@ -125,11 +125,10 @@ public sealed class StoryIntelligenceClient( { ApiKeyConfigured = !string.IsNullOrWhiteSpace(settings.ApiKey), Model = settings.Model, - Temperature = settings.Temperature, MaxOutputTokens = settings.MaxOutputTokens, TimeoutSeconds = settings.TimeoutSeconds, ClientConstructed = true, - ConnectionStatus = "Not checked. Diagnostics do not call OpenAI." + ConnectionStatus = "Not checked on diagnostics page. Only the admin dry-run page makes a live OpenAI request." }; public async Task ExecutePromptAsync(string completedPrompt, string promptVersion, CancellationToken cancellationToken) @@ -153,8 +152,16 @@ public sealed class StoryIntelligenceClient( { model = settings.Model, input = completedPrompt, - temperature = settings.Temperature, - max_output_tokens = settings.MaxOutputTokens + max_output_tokens = settings.MaxOutputTokens, + store = false, + reasoning = new + { + effort = "minimal" + }, + text = new + { + verbosity = "low" + } }, JsonOptions); var stopwatch = Stopwatch.StartNew(); @@ -230,8 +237,13 @@ public sealed class StoryIntelligenceClient( retryCount++; } - catch (TaskCanceledException) when (!cancellationToken.IsCancellationRequested && attempt < maxAttempts) + catch (TaskCanceledException) when (!cancellationToken.IsCancellationRequested) { + if (attempt == maxAttempts) + { + throw new InvalidOperationException($"OpenAI request timed out after {settings.TimeoutSeconds} seconds."); + } + retryCount++; await DelayForRetryAsync(attempt, cancellationToken); continue; @@ -283,7 +295,6 @@ public sealed class StoryIntelligenceDiagnosticsService( ConnectionStatus = clientStatus.ConnectionStatus, PromptFileName = ScenePromptFile, PromptVersion = versions.GetPromptVersion(ScenePromptFile), - Temperature = clientStatus.Temperature, MaxOutputTokens = clientStatus.MaxOutputTokens, TimeoutSeconds = clientStatus.TimeoutSeconds }; @@ -408,7 +419,6 @@ public sealed class StoryIntelligenceClientConfigurationStatus { public bool ApiKeyConfigured { get; init; } public string Model { get; init; } = string.Empty; - public decimal Temperature { get; init; } public int MaxOutputTokens { get; init; } public int TimeoutSeconds { get; init; } public bool ClientConstructed { get; init; } diff --git a/PlotLine/ViewModels/FeatureRequestViewModels.cs b/PlotLine/ViewModels/FeatureRequestViewModels.cs index 967a32e..de3dd92 100644 --- a/PlotLine/ViewModels/FeatureRequestViewModels.cs +++ b/PlotLine/ViewModels/FeatureRequestViewModels.cs @@ -81,7 +81,6 @@ public sealed class AdminDashboardViewModel public sealed class StoryIntelligenceDiagnosticsViewModel { public string Model { get; set; } = string.Empty; - public decimal Temperature { get; set; } public int MaxOutputTokens { get; set; } public int TimeoutSeconds { get; set; } public bool ApiKeyConfigured { get; set; } diff --git a/PlotLine/Views/Admin/StoryIntelligenceDiagnostics.cshtml b/PlotLine/Views/Admin/StoryIntelligenceDiagnostics.cshtml index 9bc7f28..3cfff08 100644 --- a/PlotLine/Views/Admin/StoryIntelligenceDiagnostics.cshtml +++ b/PlotLine/Views/Admin/StoryIntelligenceDiagnostics.cshtml @@ -7,7 +7,7 @@

Admin utility

Story Intelligence Diagnostics

-

Configuration and prompt loading checks. This page does not call OpenAI.

+

Build and configuration checks only. This page does not make a live OpenAI request.

@@ -46,13 +46,11 @@
-
Temperature
-
@Model.Temperature
Max output tokens
@Model.MaxOutputTokens.ToString("N0")
Timeout
@Model.TimeoutSeconds seconds
-
Connection status
+
Live API status
@Model.ConnectionStatus
@@ -95,7 +93,7 @@

Manual dry run

-

This admin-only tool loads the prompt, substitutes test scene data and performs a live OpenAI call without saving data.

+

This admin-only tool performs live API verification by loading the prompt, substituting test scene data and making one OpenAI request with extraction-focused settings. It does not save data.

Open dry run
diff --git a/PlotLine/Views/Admin/StoryIntelligenceTest.cshtml b/PlotLine/Views/Admin/StoryIntelligenceTest.cshtml index 4608268..0ea97e2 100644 --- a/PlotLine/Views/Admin/StoryIntelligenceTest.cshtml +++ b/PlotLine/Views/Admin/StoryIntelligenceTest.cshtml @@ -8,7 +8,7 @@

Admin utility

Story Intelligence Dry Run

-

This is a development dry run. It does not save data or modify projects.

+

This is a development dry run. It makes one live OpenAI extraction request only when submitted, and it does not save data or modify projects.

@@ -23,7 +23,7 @@

Manual scene test

-

Use short fictional sample text only. This page loads Scene-Prompt-V1.md, replaces runtime placeholders, and displays the raw response.

+

Use short fictional sample text only. This page loads Scene-Prompt-V1.md, replaces runtime placeholders, makes a live extraction request when submitted, and displays the raw response without parsing or saving it.

diff --git a/PlotLine/appsettings.json b/PlotLine/appsettings.json index 65fadc9..2be337f 100644 --- a/PlotLine/appsettings.json +++ b/PlotLine/appsettings.json @@ -21,7 +21,6 @@ }, "OpenAI": { "Model": "gpt-5", - "Temperature": 0.2, "MaxOutputTokens": 4000, "TimeoutSeconds": 120 },