From cb533ee4cbf6c389932b3a98fa12b7515c18d04e Mon Sep 17 00:00:00 2001 From: mathijs-bb Date: Wed, 18 Feb 2026 21:04:44 +0100 Subject: [PATCH] Fixed issue with edit action not returning an equal amount of segments --- Apps.OpenAI/Actions/EditActions.cs | 8 ++++++-- Apps.OpenAI/Apps.OpenAI.csproj | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Apps.OpenAI/Actions/EditActions.cs b/Apps.OpenAI/Actions/EditActions.cs index f6dfbb0..df05d07 100644 --- a/Apps.OpenAI/Actions/EditActions.cs +++ b/Apps.OpenAI/Actions/EditActions.cs @@ -112,9 +112,13 @@ async Task> BatchTranslate(IEnumerable<(Unit Unit catch (Exception ex) when (neverFail) { errors.Add($"Error in batch {batchCounter} (size: {batchSize}): {ex.Message}"); - } + } - return allResults; + return idSegments.Select(idPair => + { + var updatedTranslation = allResults.FirstOrDefault(x => x.TranslationId == idPair.Key); + return updatedTranslation ?? new TranslationEntity { TranslationId = idPair.Key, TranslatedText = idPair.Value.GetTarget() }; + }); } var units = content.GetUnits(); diff --git a/Apps.OpenAI/Apps.OpenAI.csproj b/Apps.OpenAI/Apps.OpenAI.csproj index 822a1c1..c07bb24 100644 --- a/Apps.OpenAI/Apps.OpenAI.csproj +++ b/Apps.OpenAI/Apps.OpenAI.csproj @@ -4,7 +4,7 @@ net8.0 OpenAI Creating safe artificial general intelligence that benefits all of humanity - 2.8.19 + 2.8.20 Apps.OpenAI