-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
34 lines (26 loc) · 1.19 KB
/
Program.cs
File metadata and controls
34 lines (26 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using A2A;
using A2A.AspNetCore;
using Azure;
using Azure.AI.OpenAI;
using A2AAgents.Shared;
using Microsoft.Extensions.AI;
using TaskAgentServer.Agents;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
TaskManager taskManager = new TaskManager();
var openAiServiceSettings = builder.Configuration.GetSection("AzureOpenAISettings").Get<AzureOpenAIServiceSettings>();
if(openAiServiceSettings == null ||
string.IsNullOrEmpty(openAiServiceSettings.Endpoint) || openAiServiceSettings.Endpoint == "YOUR_END_POINT" ||
string.IsNullOrEmpty(openAiServiceSettings.Key) || openAiServiceSettings.Key == "YOUR_API_KEY" ||
string.IsNullOrEmpty(openAiServiceSettings.DeploymentName))
throw new InvalidOperationException(
"Specify the Azure OpenAI endpoint, key, and deployment name in the 'appsettings.json' file.");
var chatClient = new AzureOpenAIClient(
new Uri(openAiServiceSettings.Endpoint),
new AzureKeyCredential(openAiServiceSettings.Key))
.GetChatClient(openAiServiceSettings.DeploymentName)
.AsIChatClient();
var agent = new TaskAgent(chatClient, taskManager);
app.UseHttpsRedirection();
app.MapA2A(taskManager, "/agent");
app.Run();