-
Notifications
You must be signed in to change notification settings - Fork 134
Expand file tree
/
Copy pathProgram.cs
More file actions
53 lines (45 loc) · 2.1 KB
/
Copy pathProgram.cs
File metadata and controls
53 lines (45 loc) · 2.1 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using Azure;
using Azure.AI.OpenAI;
using DotNetEnv;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
// Load environment variables from .env file
Env.Load("../../../../.env");
// Get Azure OpenAI configuration from environment variables
var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")
?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT is not set.");
var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT")
?? throw new InvalidOperationException("AZURE_OPENAI_DEPLOYMENT is not set.");
var apiKey = Environment.GetEnvironmentVariable("AZURE_OPENAI_KEY")
?? throw new InvalidOperationException("AZURE_OPENAI_KEY is not set.");
// Configure Azure OpenAI client for the specified deployment
var azureOpenAIClient = new AzureOpenAIClient(new Uri(endpoint), new AzureKeyCredential(apiKey));
// Planning agent configuration
const string AGENT_NAME = "TravelPlanAgent";
const string AGENT_INSTRUCTIONS = @"You are an planner agent.
Your job is to decide which agents to run based on the user's request.
Below are the available agents specialised in different tasks:
- FlightBooking: For booking flights and providing flight information
- HotelBooking: For booking hotels and providing hotel information
- CarRental: For booking cars and providing car rental information
- ActivitiesBooking: For booking activities and providing activity information
- DestinationInfo: For providing information about destinations
- DefaultAgent: For handling general request";
ChatClientAgentOptions agentOptions = new()
{
Name = AGENT_NAME,
Description = AGENT_INSTRUCTIONS,
ChatOptions = new()
{
ResponseFormat = ChatResponseFormatJson.ForJsonSchema(
schema: AIJsonUtilities.CreateJsonSchema(typeof(TravelPlan)),
schemaName: "TravelPlan",
schemaDescription: "Travel Plan with main_task and subtasks")
}
};
AIAgent agent = azureOpenAIClient
.GetChatClient(deploymentName)
.AsIChatClient()
.AsAIAgent(agentOptions);
Console.WriteLine(await agent.RunAsync("Create a travel plan for a family of 4, with 2 kids, from Singapore to Melbourne"));