mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Add extension methods to get an AF agent from a Foundry Client (#191)
* Add helpers to go from foundry client to agent more easily. * Fix xml docs.
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.Agents.Orchestration\Microsoft.Agents.Orchestration.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.Extensions.AI.Agents.AzureAI\Microsoft.Extensions.AI.Agents.AzureAI.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.Extensions.AI.Agents\Microsoft.Extensions.AI.Agents.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
+5
-11
@@ -2,7 +2,6 @@
|
||||
|
||||
using Azure.AI.Agents.Persistent;
|
||||
using Azure.Identity;
|
||||
using Microsoft.Extensions.AI;
|
||||
using Microsoft.Extensions.AI.Agents;
|
||||
using Microsoft.Shared.Samples;
|
||||
|
||||
@@ -25,19 +24,14 @@ public sealed class ChatClientAgent_With_AzureAIAgentsPersistent(ITestOutputHelp
|
||||
// Get a client to create server side agents with.
|
||||
var persistentAgentsClient = new PersistentAgentsClient(TestConfiguration.AzureAI.Endpoint, new AzureCliCredential());
|
||||
|
||||
// Create a server side agent to work with.
|
||||
var persistentAgentResponse = await persistentAgentsClient.Administration.CreateAgentAsync(
|
||||
// Create a server side persistent agent.
|
||||
var createPersistentAgentResponse = await persistentAgentsClient.Administration.CreateAgentAsync(
|
||||
model: TestConfiguration.AzureAI.DeploymentName,
|
||||
name: JokerName,
|
||||
instructions: JokerInstructions);
|
||||
|
||||
var persistentAgent = persistentAgentResponse.Value;
|
||||
|
||||
// Get the chat client to use for the agent.
|
||||
using var chatClient = persistentAgentsClient.AsIChatClient(persistentAgent.Id);
|
||||
|
||||
// Define the agent.
|
||||
ChatClientAgent agent = new(chatClient);
|
||||
// Get a local proxy for the agent to work with.
|
||||
Agent agent = await persistentAgentsClient.GetRunnableAgentAsync(createPersistentAgentResponse.Value.Id);
|
||||
|
||||
// Start a new thread for the agent conversation.
|
||||
AgentThread thread = agent.GetNewThread();
|
||||
@@ -58,6 +52,6 @@ public sealed class ChatClientAgent_With_AzureAIAgentsPersistent(ITestOutputHelp
|
||||
|
||||
// Cleanup
|
||||
await persistentAgentsClient.Threads.DeleteThreadAsync(thread.Id);
|
||||
await persistentAgentsClient.Administration.DeleteAgentAsync(persistentAgent.Id);
|
||||
await persistentAgentsClient.Administration.DeleteAgentAsync(createPersistentAgentResponse.Value.Id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user