-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathProgram.cs
More file actions
46 lines (38 loc) · 1.94 KB
/
Program.cs
File metadata and controls
46 lines (38 loc) · 1.94 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
using elbruno.Extensions.AI.Claude;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.Configuration;
// MAF Basic Chat with Claude via Microsoft Foundry
// Demonstrates using ChatClientAgent with Claude models deployed in Microsoft Foundry
// Uses elbruno.Extensions.AI.Claude package for seamless Claude integration
var config = new ConfigurationBuilder().AddUserSecrets<Program>().Build();
var endpointClaude = config["endpointClaude"] ?? throw new InvalidOperationException("Missing 'endpointClaude' configuration");
var apiKey = config["apikey"] ?? throw new InvalidOperationException("Missing 'apikey' configuration");
var deploymentName = config["deploymentName"] ?? "claude-haiku-4-5";
Console.WriteLine("=".PadRight(60, '='));
Console.WriteLine("MAF with Claude via Microsoft Foundry");
Console.WriteLine("=".PadRight(60, '='));
Console.WriteLine($"Model: {deploymentName}");
Console.WriteLine($"Endpoint: {endpointClaude}");
Console.WriteLine("=".PadRight(60, '='));
Console.WriteLine();
// Create IChatClient using elbruno.Extensions.AI.Claude package
IChatClient chatClient = new AzureClaudeClient(
endpoint: new Uri(endpointClaude),
modelId: deploymentName,
apiKey: apiKey);
// Create AI Agent with ChatClientAgent
AIAgent writer = chatClient.AsAIAgent(
name: "Writer",
instructions: "You are a creative writer who crafts engaging and imaginative stories. Keep responses concise but vivid.");
// Run the agent with a prompt
Console.WriteLine("Prompt: Write a short story about a haunted house with a character named Lucia.");
Console.WriteLine();
Console.WriteLine("Response:");
Console.WriteLine("-".PadRight(60, '-'));
AgentResponse response = await writer.RunAsync("Write a short story about a haunted house with a character named Lucia.");
Console.WriteLine(response.Text);
Console.WriteLine("-".PadRight(60, '-'));
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();