Skip to content

Commit b2d5179

Browse files
239573049crickmanmarkwallace-microsoft
authored
.Net: Refactor kernel initialization in Step01_Agent (#12181)
This pull request updates the `UseSingleChatCompletionAgent` method in `Step01_Agent.cs` to improve code clarity and reusability. The most important change is replacing the call to `CreateKernelWithChatCompletion()` with the existing `kernel` parameter. Code clarity and reusability: * [`dotnet/samples/GettingStartedWithAgents/Step01_Agent.cs`](diffhunk://#diff-406533ddffa54164a374596ac14a8eb4f1b07ed75f8a235d349c4086cc69dbc5L36-R36): Updated the `Kernel` property to use the `kernel` parameter instead of calling `CreateKernelWithChatCompletion()`. This change removes redundancy and simplifies the method. Co-authored-by: Chris <[email protected]> Co-authored-by: Mark Wallace <[email protected]>
1 parent 6ecf2b9 commit b2d5179

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

dotnet/samples/GettingStartedWithAgents/Step01_Agent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ public class Step01_Agent(ITestOutputHelper output) : BaseAgentsTest(output)
2727
[InlineData(false)]
2828
public async Task UseSingleChatCompletionAgent(bool useChatClient)
2929
{
30-
Kernel kernel = this.CreateKernelWithChatCompletion();
30+
Kernel kernel = this.CreateKernelWithChatCompletion(useChatClient, out var chatClient);
3131

3232
// Define the agent
3333
ChatCompletionAgent agent =
3434
new()
3535
{
3636
Name = ParrotName,
3737
Instructions = ParrotInstructions,
38-
Kernel = this.CreateKernelWithChatCompletion(useChatClient, out var chatClient),
38+
Kernel = kernel
3939
};
4040

4141
// Respond to user input

0 commit comments

Comments
 (0)