mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Hosting Samples update
This commit is contained in:
committed by
alliscode
Unverified
parent
bf779f2029
commit
3984ef4ef1
@@ -274,14 +274,14 @@
|
||||
<Project Path="samples/04-hosting/FoundryHostedAgents/HostedAgentsV1/FoundrySingleAgent/FoundrySingleAgent.csproj" />
|
||||
</Folder>
|
||||
<Folder Name="/Samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/" />
|
||||
<Folder Name="/Samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Client-Agent/">
|
||||
<Project Path="samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/consumption/SimpleAgent.csproj" />
|
||||
</Folder>
|
||||
<Folder Name="/Samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Hosted-ChatClientAgent/">
|
||||
<Project Path="samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/instance-hosting/HostedChatClientAgent.csproj" />
|
||||
</Folder>
|
||||
<Folder Name="/Samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/Hosted-FoundryAgent/">
|
||||
<Project Path="samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/simple-agent-foundry.csproj" />
|
||||
<Project Path="samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/foundry-hosting/HostedFoundryAgent.csproj" />
|
||||
</Folder>
|
||||
<Folder Name="/Samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/UsingHostedAgent/">
|
||||
<Project Path="samples/04-hosting/FoundryHostedAgents/HostedAgentsV2/consumption/SimpleAgent.csproj" />
|
||||
</Folder>
|
||||
<Folder Name="/Samples/04-hosting/FoundryResponsesHosting/">
|
||||
<Project Path="samples/04-hosting/FoundryResponsesHosting/FoundryResponsesHosting.csproj" />
|
||||
|
||||
@@ -8,7 +8,7 @@ using Microsoft.Agents.AI;
|
||||
// Load .env file if present (for local development)
|
||||
Env.TraversePath().Load();
|
||||
|
||||
string agentEndpoint = Environment.GetEnvironmentVariable("AGENT_ENDPOINT") ?? "http://localhost:8088";
|
||||
string agentEndpoint = Environment.GetEnvironmentVariable("AGENT_ENDPOINT") ?? "http://localhost:59055";
|
||||
|
||||
// ── Create an agent-framework agent backed by the remote agent endpoint ──────
|
||||
// The Foundry Agent SDK's AIProjectClient can target any OpenAI-compatible endpoint.
|
||||
@@ -21,11 +21,13 @@ AgentSession session = await agent.CreateSessionAsync();
|
||||
// ── REPL ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||
Console.WriteLine("╔══════════════════════════════════════════════════════════╗");
|
||||
Console.WriteLine("║ Simple Agent Client ║");
|
||||
Console.WriteLine($"║ Connected to: {agentEndpoint,-41}║");
|
||||
Console.WriteLine("║ Type a message or 'quit' to exit ║");
|
||||
Console.WriteLine("╚══════════════════════════════════════════════════════════╝");
|
||||
Console.WriteLine($"""
|
||||
══════════════════════════════════════════════════════════
|
||||
Simple Agent Sample
|
||||
Connected to: {agentEndpoint}
|
||||
Type a message or 'quit' to exit
|
||||
══════════════════════════════════════════════════════════
|
||||
""");
|
||||
Console.ResetColor();
|
||||
Console.WriteLine();
|
||||
|
||||
@@ -38,9 +40,7 @@ while (true)
|
||||
string? input = Console.ReadLine();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(input)) { continue; }
|
||||
if (input.Equals("quit", StringComparison.OrdinalIgnoreCase) ||
|
||||
input.Equals("exit", StringComparison.OrdinalIgnoreCase))
|
||||
{ break; }
|
||||
if (input.Equals("quit", StringComparison.OrdinalIgnoreCase)) { break; }
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
+4
-2
@@ -1,8 +1,10 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using Azure.AI.Projects;
|
||||
using Azure.AI.Projects.Agents;
|
||||
using Azure.Identity;
|
||||
using DotNetEnv;
|
||||
using Microsoft.Agents.AI;
|
||||
using Microsoft.Agents.AI.Foundry;
|
||||
using Microsoft.Agents.AI.Foundry.Hosting;
|
||||
|
||||
// Load .env file if present (for local development)
|
||||
@@ -19,7 +21,7 @@ var aiProjectClient = new AIProjectClient(projectEndpoint, new DefaultAzureCrede
|
||||
ProjectsAgentRecord agentRecord = await aiProjectClient
|
||||
.AgentAdministrationClient.GetAgentAsync(agentName);
|
||||
|
||||
AIAgent agent = aiProjectClient.AsAIAgent(agentRecord);
|
||||
FoundryAgent agent = aiProjectClient.AsAIAgent(agentRecord);
|
||||
|
||||
// Host the agent as a Foundry Hosted Agent using the Responses API.
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:59703;http://localhost:59708"
|
||||
"applicationUrl": "http://localhost:8089"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user