From 513cfc4fd846a5fd3e3e746bbc29119c41bc0678 Mon Sep 17 00:00:00 2001 From: Darren Fuller Date: Tue, 30 Dec 2025 13:38:25 +0000 Subject: [PATCH 1/7] Add .NET 10.0 to target frameworks --- DotPrompt.Tests/DotPrompt.Tests.csproj | 2 +- DotPrompt/DotPrompt.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DotPrompt.Tests/DotPrompt.Tests.csproj b/DotPrompt.Tests/DotPrompt.Tests.csproj index bd81673..8683407 100644 --- a/DotPrompt.Tests/DotPrompt.Tests.csproj +++ b/DotPrompt.Tests/DotPrompt.Tests.csproj @@ -1,7 +1,7 @@ - net8.0;net9.0 + net8.0;net9.0;net10.0 enable enable diff --git a/DotPrompt/DotPrompt.csproj b/DotPrompt/DotPrompt.csproj index 7525f8a..ad0d01b 100644 --- a/DotPrompt/DotPrompt.csproj +++ b/DotPrompt/DotPrompt.csproj @@ -1,7 +1,7 @@  - net8.0;net9.0 + net8.0;net9.0;net10.0 enable enable DotPrompt From 87384da03e79e0dc7fc92fabc6e5e2b98e9d3faf Mon Sep 17 00:00:00 2001 From: Darren Fuller Date: Tue, 30 Dec 2025 13:43:08 +0000 Subject: [PATCH 2/7] Update package dependencies to latest versions --- DotPrompt.Tests/DotPrompt.Tests.csproj | 4 ++-- DotPrompt/DotPrompt.csproj | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/DotPrompt.Tests/DotPrompt.Tests.csproj b/DotPrompt.Tests/DotPrompt.Tests.csproj index 8683407..54874fb 100644 --- a/DotPrompt.Tests/DotPrompt.Tests.csproj +++ b/DotPrompt.Tests/DotPrompt.Tests.csproj @@ -10,9 +10,9 @@ - + - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/DotPrompt/DotPrompt.csproj b/DotPrompt/DotPrompt.csproj index ad0d01b..9080d48 100644 --- a/DotPrompt/DotPrompt.csproj +++ b/DotPrompt/DotPrompt.csproj @@ -21,9 +21,9 @@ - - - + + + From e26c201f4009af9437883635906652954641fea1 Mon Sep 17 00:00:00 2001 From: Darren Fuller Date: Tue, 30 Dec 2025 13:43:46 +0000 Subject: [PATCH 3/7] update to use new extension block syntax --- .../Extensions/OpenAi/OpenAiExtensions.cs | 109 +++++++++--------- 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/DotPrompt/Extensions/OpenAi/OpenAiExtensions.cs b/DotPrompt/Extensions/OpenAi/OpenAiExtensions.cs index d5ba39c..ac8e69a 100644 --- a/DotPrompt/Extensions/OpenAi/OpenAiExtensions.cs +++ b/DotPrompt/Extensions/OpenAi/OpenAiExtensions.cs @@ -7,73 +7,74 @@ namespace DotPrompt.Extensions.OpenAi; /// public static class OpenAiExtensions { - /// - /// Converts a instance to a collection of objects. - /// /// The instance containing prompt definitions. - /// A dictionary of values to be substituted in the user prompt template. - /// An enumerable collection of objects. - public static IEnumerable ToOpenAiChatMessages(this PromptFile promptFile, - IDictionary? values) + extension(PromptFile promptFile) { - var messages = new List(); - - // If the prompt file provides any few shot prompts, then include these first - if (promptFile.FewShots.Length != 0) + /// + /// Converts a instance to a collection of objects. + /// + /// A dictionary of values to be substituted in the user prompt template. + /// An enumerable collection of objects. + public IEnumerable ToOpenAiChatMessages(IDictionary? values) { - foreach (var fewShot in promptFile.FewShots) + var messages = new List(); + + // If the prompt file provides any few shot prompts, then include these first + if (promptFile.FewShots.Length != 0) { - messages.Add(new UserChatMessage(fewShot.User)); - messages.Add(new AssistantChatMessage(fewShot.Response)); + foreach (var fewShot in promptFile.FewShots) + { + messages.Add(new UserChatMessage(fewShot.User)); + messages.Add(new AssistantChatMessage(fewShot.Response)); + } } - } - if (!string.IsNullOrEmpty(promptFile.Prompts!.System)) - { - messages.Add(new SystemChatMessage(promptFile.GetSystemPrompt(values))); - } + if (!string.IsNullOrEmpty(promptFile.Prompts!.System)) + { + messages.Add(new SystemChatMessage(promptFile.GetSystemPrompt(values))); + } - messages.Add(new UserChatMessage(promptFile.GetUserPrompt(values))); + messages.Add(new UserChatMessage(promptFile.GetUserPrompt(values))); - return messages; - } + return messages; + } - /// - /// Converts a instance to an object. - /// - /// The instance containing configuration and prompt definitions. - /// A object configured based on the instance. - public static ChatCompletionOptions ToOpenAiChatCompletionOptions(this PromptFile promptFile) - { - var chatResponseFormat = promptFile.Config.OutputFormat switch + /// + /// Converts a instance to an object. + /// + /// A object configured based on the instance. + public ChatCompletionOptions ToOpenAiChatCompletionOptions() { - OutputFormat.Text => ChatResponseFormat.CreateTextFormat(), - OutputFormat.Json => ChatResponseFormat.CreateJsonObjectFormat(), - OutputFormat.JsonSchema when promptFile.Config.Output?.Schema is not null => - ChatResponseFormat.CreateJsonSchemaFormat( - promptFile.Name, - BinaryData.FromString(promptFile.Config.Output.ToSchemaDocument()), - jsonSchemaIsStrict: true), - OutputFormat.JsonSchema when promptFile.Config.Output?.Schema is null => - throw new DotPromptException("A valid schema was not provided to be used with the JsonSchema response type"), - _ => throw new DotPromptException("The requested output format is not available") - }; + var chatResponseFormat = promptFile.Config.OutputFormat switch + { + OutputFormat.Text => ChatResponseFormat.CreateTextFormat(), + OutputFormat.Json => ChatResponseFormat.CreateJsonObjectFormat(), + OutputFormat.JsonSchema when promptFile.Config.Output?.Schema is not null => + ChatResponseFormat.CreateJsonSchemaFormat( + promptFile.Name, + BinaryData.FromString(promptFile.Config.Output.ToSchemaDocument()), + jsonSchemaIsStrict: true), + OutputFormat.JsonSchema when promptFile.Config.Output?.Schema is null => + throw new DotPromptException("A valid schema was not provided to be used with the JsonSchema response type"), + _ => throw new DotPromptException("The requested output format is not available") + }; - var chatCompletionOptions = new ChatCompletionOptions - { - ResponseFormat = chatResponseFormat - }; + var chatCompletionOptions = new ChatCompletionOptions + { + ResponseFormat = chatResponseFormat + }; - if (promptFile.Config.Temperature is not null) - { - chatCompletionOptions.Temperature = promptFile.Config.Temperature; - } + if (promptFile.Config.Temperature is not null) + { + chatCompletionOptions.Temperature = promptFile.Config.Temperature; + } - if (promptFile.Config.MaxTokens is not null) - { - chatCompletionOptions.MaxOutputTokenCount = promptFile.Config.MaxTokens; - } + if (promptFile.Config.MaxTokens is not null) + { + chatCompletionOptions.MaxOutputTokenCount = promptFile.Config.MaxTokens; + } - return chatCompletionOptions; + return chatCompletionOptions; + } } } \ No newline at end of file From 7498323dc7086d89f9d6ee2525bccdfb096cf1d9 Mon Sep 17 00:00:00 2001 From: Darren Fuller Date: Tue, 30 Dec 2025 13:49:44 +0000 Subject: [PATCH 4/7] remove redundant null assignment in _schemaDocument initialization --- DotPrompt/Output.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DotPrompt/Output.cs b/DotPrompt/Output.cs index abd9ad6..746c82e 100644 --- a/DotPrompt/Output.cs +++ b/DotPrompt/Output.cs @@ -8,7 +8,7 @@ namespace DotPrompt; /// public class Output { - private string? _schemaDocument = null; + private string? _schemaDocument; /// /// Gets or sets the format of the output. This determines how the output should be structured. From b80ec7efb96c78f0a2ca5a3259e51b61148b46ae Mon Sep 17 00:00:00 2001 From: Darren Fuller Date: Tue, 30 Dec 2025 13:50:06 +0000 Subject: [PATCH 5/7] remove unused Json.Schema namespace --- DotPrompt/PromptFile.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/DotPrompt/PromptFile.cs b/DotPrompt/PromptFile.cs index eb9b548..379d937 100644 --- a/DotPrompt/PromptFile.cs +++ b/DotPrompt/PromptFile.cs @@ -1,7 +1,6 @@ using System.Globalization; using System.Text.RegularExpressions; using Fluid; -using Json.Schema; using YamlDotNet.Core; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; From 824341d2e681197ddda979aa06c0c9213ad45f43 Mon Sep 17 00:00:00 2001 From: Darren Fuller Date: Tue, 30 Dec 2025 13:50:21 +0000 Subject: [PATCH 6/7] replace var with const for expectedPrompt in PromptFileTests --- DotPrompt.Tests/PromptFileTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DotPrompt.Tests/PromptFileTests.cs b/DotPrompt.Tests/PromptFileTests.cs index 80d6e65..11ac5fb 100644 --- a/DotPrompt.Tests/PromptFileTests.cs +++ b/DotPrompt.Tests/PromptFileTests.cs @@ -329,7 +329,7 @@ public void GenerateUserPrompt_WithAllParameterValues_GeneratesValidPrompt() { var promptFile = PromptFile.FromFile("SamplePrompts/param-types.prompt"); - var expectedPrompt = + const string expectedPrompt = "Parameter 1: Arthur Dent\nParameter 2: 42\nParameter 3: true\nParameter 4: 2024-01-02 03:04:05Z\nParameter 5: { SEP = True }\nParameter 6: Hello : 12"; var userPrompt = promptFile.GetUserPrompt(new Dictionary From 270370cf83a647d47f71040d4a7ecec18692238e Mon Sep 17 00:00:00 2001 From: Darren Fuller Date: Tue, 30 Dec 2025 13:53:22 +0000 Subject: [PATCH 7/7] update workflows to use .NET 10.0 --- .github/workflows/dotnet.yml | 2 +- .github/workflows/release.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 609b21f..ee86018 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -20,7 +20,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 9.0.x + dotnet-version: 10.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2e68b0e..23ebda2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -14,7 +14,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 9.0.x + dotnet-version: 10.0.x - name: Get latest tag version id: vars run: echo "tag=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_OUTPUT