mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
.NET: Fix Semantic Kernel migration samples (#739)
* use GetOpenAIResponseClient Signed-off-by: Jianguo Ma <jiangma@microsoft.com> * use PersistentAgentsClient Signed-off-by: Jianguo Ma <jiangma@microsoft.com> --------- Signed-off-by: Jianguo Ma <jiangma@microsoft.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
8af4918f56
commit
2a75482777
+1
-1
@@ -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<AIAgent>((sp) =>
|
||||
{
|
||||
var azureAgentClient = sp.GetRequiredService<PersistentAgentsClient>();
|
||||
|
||||
+1
-1
@@ -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");
|
||||
|
||||
+1
-1
@@ -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();
|
||||
|
||||
@@ -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)]);
|
||||
|
||||
|
||||
+1
-1
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user