diff --git a/dotnet/Directory.Packages.props b/dotnet/Directory.Packages.props index 233be81237d8..8ea8825027bb 100644 --- a/dotnet/Directory.Packages.props +++ b/dotnet/Directory.Packages.props @@ -16,7 +16,7 @@ - + @@ -62,9 +62,9 @@ - - - + + + @@ -106,8 +106,8 @@ - - + + @@ -130,7 +130,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/dotnet/src/SemanticKernel.Abstractions/AI/ChatCompletion/ChatClientChatCompletionService.cs b/dotnet/src/SemanticKernel.Abstractions/AI/ChatCompletion/ChatClientChatCompletionService.cs index 62aad390dea4..d7952fa42afa 100644 --- a/dotnet/src/SemanticKernel.Abstractions/AI/ChatCompletion/ChatClientChatCompletionService.cs +++ b/dotnet/src/SemanticKernel.Abstractions/AI/ChatCompletion/ChatClientChatCompletionService.cs @@ -130,6 +130,11 @@ public async IAsyncEnumerable GetStreamingChatMessa { options.TopK = topK; } + else if (entry.Key.Equals("seed", StringComparison.OrdinalIgnoreCase) && + TryConvert(entry.Value, out long seed)) + { + options.Seed = seed; + } else if (entry.Key.Equals("max_tokens", StringComparison.OrdinalIgnoreCase) && TryConvert(entry.Value, out int maxTokens)) { diff --git a/dotnet/src/SemanticKernel.Abstractions/AI/ChatCompletion/ChatCompletionServiceChatClient.cs b/dotnet/src/SemanticKernel.Abstractions/AI/ChatCompletion/ChatCompletionServiceChatClient.cs index 1d76df963b06..cab0bce50d26 100644 --- a/dotnet/src/SemanticKernel.Abstractions/AI/ChatCompletion/ChatCompletionServiceChatClient.cs +++ b/dotnet/src/SemanticKernel.Abstractions/AI/ChatCompletion/ChatCompletionServiceChatClient.cs @@ -138,6 +138,11 @@ public void Dispose() settings.ExtensionData["top_k"] = options.TopK.Value; } + if (options.Seed is not null) + { + settings.ExtensionData["seed"] = options.Seed.Value; + } + if (options.ResponseFormat is not null) { if (options.ResponseFormat is ChatResponseFormatText) diff --git a/dotnet/src/SemanticKernel.UnitTests/AI/ServiceConversionExtensionsTests.cs b/dotnet/src/SemanticKernel.UnitTests/AI/ServiceConversionExtensionsTests.cs index d4dad01050d7..09f1966e2837 100644 --- a/dotnet/src/SemanticKernel.UnitTests/AI/ServiceConversionExtensionsTests.cs +++ b/dotnet/src/SemanticKernel.UnitTests/AI/ServiceConversionExtensionsTests.cs @@ -526,7 +526,7 @@ public async Task AsChatCompletionServiceNonStreamingContentConvertedAsExpected( Assert.Equal(0.5f, actualOptions.FrequencyPenalty); Assert.Equal(0.75f, actualOptions.TopP); Assert.Equal(["hello"], actualOptions.StopSequences); - Assert.Equal(42, actualOptions.AdditionalProperties?.TryGetValue("Seed", out int seed) is true ? seed : 0); + Assert.Equal(42, actualOptions.Seed); Assert.Equal("user123", actualOptions.AdditionalProperties?["User"]); } @@ -621,7 +621,7 @@ public async Task AsChatCompletionServiceStreamingContentConvertedAsExpected() Assert.Equal(0.5f, actualOptions.FrequencyPenalty); Assert.Equal(0.75f, actualOptions.TopP); Assert.Equal(["hello"], actualOptions.StopSequences); - Assert.Equal(42, actualOptions.AdditionalProperties?.TryGetValue("Seed", out int seed) is true ? seed : 0); + Assert.Equal(42, actualOptions.Seed); Assert.Equal("user123", actualOptions.AdditionalProperties?["User"]); }