|
1 | 1 | // Copyright (c) Microsoft. All rights reserved. |
2 | 2 |
|
3 | | -using Amazon.BedrockRuntime; |
| 3 | +using Google.GenAI; |
4 | 4 | using Microsoft.Agents.AI; |
5 | 5 | using Microsoft.Agents.AI.Workflows; |
6 | 6 | using Microsoft.Extensions.AI; |
|
9 | 9 | const string Topic = "Goldendoodles make the best pets."; |
10 | 10 |
|
11 | 11 | // Create the IChatClients to talk to different services. |
12 | | -IChatClient aws = new AmazonBedrockRuntimeClient( |
13 | | - Environment.GetEnvironmentVariable("BEDROCK_ACCESS_KEY"!), |
14 | | - Environment.GetEnvironmentVariable("BEDROCK_SECRET_KEY")!, |
15 | | - Amazon.RegionEndpoint.USEast1) |
16 | | - .AsIChatClient("amazon.nova-pro-v1:0"); |
| 12 | +IChatClient google = new Client(vertexAI: false, apiKey: Environment.GetEnvironmentVariable("GOOGLE_GENAI_API_KEY")) |
| 13 | + .AsIChatClient("gemini-2.5-flash"); |
17 | 14 |
|
18 | 15 | IChatClient anthropic = new Anthropic.AnthropicClient( |
19 | 16 | new() { ApiKey = Environment.GetEnvironmentVariable("ANTHROPIC_API_KEY") }) |
20 | 17 | .AsIChatClient("claude-sonnet-4-20250514"); |
21 | 18 |
|
22 | 19 | IChatClient openai = new OpenAI.OpenAIClient( |
23 | | - Environment.GetEnvironmentVariable("OPENAI_API_KEY")!).GetChatClient("gpt-4o-mini") |
24 | | - .AsIChatClient(); |
| 20 | + Environment.GetEnvironmentVariable("OPENAI_API_KEY")) |
| 21 | + .GetResponsesClient() |
| 22 | + .AsIChatClient("gpt-4o-mini"); |
25 | 23 |
|
26 | 24 | // Define our agents. |
27 | | -AIAgent researcher = new ChatClientAgent(aws, |
| 25 | +AIAgent researcher = new ChatClientAgent(google, |
28 | 26 | instructions: """ |
29 | 27 | Write a short essay on topic specified by the user. The essay should be three to five paragraphs, written at a |
30 | 28 | high school reading level, and include relevant background information, key claims, and notable perspectives. |
@@ -60,6 +58,12 @@ You MUST NOT provide any commentary on what you're doing. Simply output the fina |
60 | 58 | string? lastAuthor = null; |
61 | 59 | await foreach (var update in workflowAgent.RunStreamingAsync(Topic)) |
62 | 60 | { |
| 61 | + // Skip WorkflowEvent-only updates |
| 62 | + if ((update.Contents == null || update.Contents.Count == 0) && update.RawRepresentation is WorkflowEvent) |
| 63 | + { |
| 64 | + continue; |
| 65 | + } |
| 66 | + |
63 | 67 | if (lastAuthor != update.AuthorName) |
64 | 68 | { |
65 | 69 | lastAuthor = update.AuthorName; |
|
0 commit comments