From 2a7548277721c96d95d9931ce5f4804813e1748d Mon Sep 17 00:00:00 2001 From: Jianguo Ma Date: Mon, 15 Sep 2025 15:49:41 +0800 Subject: [PATCH] .NET: Fix Semantic Kernel migration samples (#739) * use GetOpenAIResponseClient Signed-off-by: Jianguo Ma * use PersistentAgentsClient Signed-off-by: Jianguo Ma --------- Signed-off-by: Jianguo Ma --- .../AzureAIFoundry/Step03_DependencyInjection/Program.cs | 2 +- .../AzureOpenAIResponses/Step03_ToolCall/Program.cs | 2 +- .../AzureOpenAIResponses/Step04_DependencyInjection/Program.cs | 2 +- .../OpenAIResponses/Step03_ToolCall/Program.cs | 2 +- .../OpenAIResponses/Step04_DependencyInjection/Program.cs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dotnet/samples/SemanticKernelMigration/AzureAIFoundry/Step03_DependencyInjection/Program.cs b/dotnet/samples/SemanticKernelMigration/AzureAIFoundry/Step03_DependencyInjection/Program.cs index e944c02091..02d8250fa7 100644 --- a/dotnet/samples/SemanticKernelMigration/AzureAIFoundry/Step03_DependencyInjection/Program.cs +++ b/dotnet/samples/SemanticKernelMigration/AzureAIFoundry/Step03_DependencyInjection/Program.cs @@ -66,7 +66,7 @@ async Task AFAgent() Console.WriteLine("\n=== AF Agent ===\n"); var serviceCollection = new ServiceCollection(); - serviceCollection.AddSingleton((sp) => AzureAIAgent.CreateAgentsClient(azureEndpoint, new AzureCliCredential())); + serviceCollection.AddSingleton((sp) => new PersistentAgentsClient(azureEndpoint, new AzureCliCredential())); serviceCollection.AddTransient((sp) => { var azureAgentClient = sp.GetRequiredService(); diff --git a/dotnet/samples/SemanticKernelMigration/AzureOpenAIResponses/Step03_ToolCall/Program.cs b/dotnet/samples/SemanticKernelMigration/AzureOpenAIResponses/Step03_ToolCall/Program.cs index 9c9ab8995c..b6fa282185 100644 --- a/dotnet/samples/SemanticKernelMigration/AzureOpenAIResponses/Step03_ToolCall/Program.cs +++ b/dotnet/samples/SemanticKernelMigration/AzureOpenAIResponses/Step03_ToolCall/Program.cs @@ -46,7 +46,7 @@ async Task SKAgent() async Task AFAgent() { var agent = new AzureOpenAIClient(new Uri(endpoint), new AzureCliCredential()) - .GetChatClient(deploymentName) + .GetOpenAIResponseClient(deploymentName) .CreateAIAgent(instructions: "You are a helpful assistant", tools: [AIFunctionFactory.Create(GetWeather)]); Console.WriteLine("\n=== AF Agent Response ===\n"); diff --git a/dotnet/samples/SemanticKernelMigration/AzureOpenAIResponses/Step04_DependencyInjection/Program.cs b/dotnet/samples/SemanticKernelMigration/AzureOpenAIResponses/Step04_DependencyInjection/Program.cs index 53e65b4c3b..f1a1ba9c93 100644 --- a/dotnet/samples/SemanticKernelMigration/AzureOpenAIResponses/Step04_DependencyInjection/Program.cs +++ b/dotnet/samples/SemanticKernelMigration/AzureOpenAIResponses/Step04_DependencyInjection/Program.cs @@ -45,7 +45,7 @@ async Task AFAgent() var serviceCollection = new ServiceCollection(); serviceCollection.AddTransient((sp) => new AzureOpenAIClient(new Uri(endpoint), new AzureCliCredential()) - .GetChatClient(deploymentName) + .GetOpenAIResponseClient(deploymentName) .CreateAIAgent(name: "Joker", instructions: "You are good at telling jokes.")); await using ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider(); diff --git a/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step03_ToolCall/Program.cs b/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step03_ToolCall/Program.cs index c7de76df78..2cfb51bdf2 100644 --- a/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step03_ToolCall/Program.cs +++ b/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step03_ToolCall/Program.cs @@ -44,7 +44,7 @@ async Task SKAgent() async Task AFAgent() { - var agent = new OpenAIClient(apiKey).GetChatClient(modelId).CreateAIAgent( + var agent = new OpenAIClient(apiKey).GetOpenAIResponseClient(modelId).CreateAIAgent( instructions: "You are a helpful assistant", tools: [AIFunctionFactory.Create(GetWeather)]); diff --git a/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step04_DependencyInjection/Program.cs b/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step04_DependencyInjection/Program.cs index 36f38a5fe9..be629d8e7e 100644 --- a/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step04_DependencyInjection/Program.cs +++ b/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step04_DependencyInjection/Program.cs @@ -42,7 +42,7 @@ async Task AFAgent() var serviceCollection = new ServiceCollection(); serviceCollection.AddTransient((sp) => new OpenAIClient(apiKey) - .GetChatClient(modelId) + .GetOpenAIResponseClient(modelId) .CreateAIAgent(name: "Joker", instructions: "You are good at telling jokes.")); await using ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();