Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Apps.OpenAI/Apps.OpenAI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Product>OpenAI</Product>
<Description>Creating safe artificial general intelligence that benefits all of humanity</Description>
<Version>2.8.10</Version>
<Version>2.8.11</Version>
<AssemblyName>Apps.OpenAI</AssemblyName>
</PropertyGroup>

Expand Down
3 changes: 2 additions & 1 deletion Apps.OpenAI/Services/JsonGlossaryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ private class GlossaryJson
}

var glossaryStream = await fileManagementClient.DownloadAsync(glossary);
var blackbirdGlossary = await glossaryStream.ConvertFromTbx();
using var sanitizedGlossaryStream = await glossaryStream.SanitizeTbxXmlAsync();
var blackbirdGlossary = await sanitizedGlossaryStream.ConvertFromTbx();

var jsonGlossary = new GlossaryJson();
var entriesIncluded = false;
Expand Down
2 changes: 1 addition & 1 deletion Apps.OpenAI/Services/PostEditService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private async Task<BatchResult> ProcessBatchAsync(
catch (Exception ex)
{
result.IsSuccess = false;
result.ErrorMessages.Add($"Unexpected error processing batch: {ex.Message}");
result.ErrorMessages.Add($"Unexpected error processing batch: {ex.GetType().Name}: {ex.Message}");
return result;
}
}
Expand Down
9 changes: 5 additions & 4 deletions Tests.OpenAI/TranslationActionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ public async Task Translate_html(InvocationContext context)
var modelIdentifier = new TextChatModelIdentifier { ModelId = "gpt-5-mini" };
var translateRequest = new TranslateContentRequest
{
File = new FileReference { Name = "" },
File = new FileReference { Name = "Pasted text-en-ko-Tr.mxliff" },
TargetLanguage = "zh-Hans-CN",
OutputFileHandling = "original"
OutputFileHandling = "original",

};
var reasoningEffortRequest = new ReasoningEffortRequest();
var reasoningEffortRequest = new ReasoningEffortRequest { };
string systemMessage = "";
var glossaryRequest = new GlossaryRequest { Glossary = new FileReference { Name = "Glossary.tbx" } };
var glossaryRequest = new GlossaryRequest { Glossary = new FileReference { Name = "Glossary.tbx" } };

var result = await actions.TranslateContent(modelIdentifier, translateRequest, systemMessage, glossaryRequest, reasoningEffortRequest);
Assert.IsNotNull(result);
Expand Down
23 changes: 13 additions & 10 deletions Tests.OpenAI/XliffActionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,33 @@
using Blackbird.Applications.Sdk.Common.Exceptions;
using Blackbird.Applications.Sdk.Common.Files;
using Blackbird.Applications.Sdk.Common.Invocation;
using Apps.OpenAI.Constants;

namespace Tests.OpenAI;

[TestClass]
public class XliffActionTests : TestBaseWithContext
{
[TestMethod, ContextDataSource]
[TestMethod, ContextDataSource(ConnectionTypes.AzureOpenAi)]
public async Task PostEditXLIFF_WithValidXlfFile_ProcessesSuccessfully(InvocationContext context)
{
// Arrange
var actions = new DeprecatedXliffActions(context, FileManagementClient);
var modelIdentifier = new TextChatModelIdentifier { ModelId = "gpt-4.1" };
var prompt = "You are a Swiss machine translation post-editor. You edit texts from German into Italian. Your task is to post-edit a translation. You need to take the source segment into account when post-editing the translation. Check each target segment and perform the following tasks:\r\n- Replace the character \"'\" with the character \"’\". Example: write \"l’indice\" instead of \"l'indice\".\r\n- Make sure that the quotation marks \"«»\" are used in the target text. Example: write «I prezzi aumentano» instead of \"I prezzi aumentano\".\r\n- Make sure percentages are expressed with the symbol \"%\". Make sure there aren't spaces between the number and the symbol. Example: write \"10%\" instead of “10 per cento”.\r\n- Perform a grammar and punctuation check. Focus on spelling, gender and number. Ensure internal consistency and fluency. Try to use impersonal formulations when possible.\r\n- Perform a terminology check. The attached glossary contains the terms that need to be strictly applied to the translation, ensuring grammatical correctness, gender, inflections and plurals.\r\nReturn the new .xliff file. ";

var modelIdentifier = new TextChatModelIdentifier { /*ModelId = "gpt-4.1" */};
var prompt = "";
var editRequest = new PostEditXliffRequest
{
DisableTagChecks = true,
File = new FileReference { Name = "contentful.html.xliff" },
SourceLanguage = "German",
TargetLanguage = "Italian",

//DisableTagChecks = true,
File = new FileReference { Name = "Pasted text-en-ko-Tr.mxliff" },
//SourceLanguage = "German",
//TargetLanguage = "Italian",
NeverFail = false,
ModifiedBy= "1441948",
FilterGlossary=true,
PostEditLockedSegments = false
};
string? systemMessage = prompt;
var glossaryRequest = new GlossaryRequest { Glossary = new FileReference { Name = "glossary.tbx" } };
var glossaryRequest = new GlossaryRequest { Glossary = new FileReference { Name = "TermWeb_Safe For AI.tbx" } };

// Act
var result = await actions.PostEditXLIFF(modelIdentifier, editRequest, systemMessage, glossaryRequest);
Expand Down