Skip to content

Commit da74476

Browse files
authored
.Net: Fix BaseTest (#12208)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> We are seeing exceptions in some samples due to a bug in the `BaseTest.cs` module, that ignores the `modelName` parameter when creating a kernel with chat completion. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> This PR ensures that the `modelName` parameter is consistently passed to the `AddChatCompletionToKernel` method. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
1 parent 53f0cb8 commit da74476

File tree

1 file changed

+2
-3
lines changed
  • dotnet/src/InternalUtilities/samples/InternalUtilities

1 file changed

+2
-3
lines changed

dotnet/src/InternalUtilities/samples/InternalUtilities/BaseTest.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,20 @@ public abstract class BaseTest : TextWriter
5050
protected bool UseBingSearch => TestConfiguration.Bing.ApiKey is not null;
5151

5252
protected Kernel CreateKernelWithChatCompletion(string? modelName = null)
53-
=> this.CreateKernelWithChatCompletion(useChatClient: false, out _);
53+
=> this.CreateKernelWithChatCompletion(useChatClient: false, out _, modelName);
5454

5555
protected Kernel CreateKernelWithChatCompletion(bool useChatClient, out IChatClient? chatClient, string? modelName = null)
5656
{
5757
var builder = Kernel.CreateBuilder();
5858

59-
AddChatCompletionToKernel(builder, modelName);
6059
if (useChatClient)
6160
{
6261
chatClient = AddChatClientToKernel(builder);
6362
}
6463
else
6564
{
6665
chatClient = null;
67-
AddChatCompletionToKernel(builder);
66+
AddChatCompletionToKernel(builder, modelName);
6867
}
6968

7069
return builder.Build();

0 commit comments

Comments
 (0)