mirror of
https://github.com/microsoft/autogen.git
synced 2025-06-26 22:30:10 +00:00

* There was an inconsistentcy between the package names that prevented xlang from working even though the actual types were 1:1 compatible * Also moves the HelloAgent aspire project into the Hello solution folder
18 lines
829 B
C#
18 lines
829 B
C#
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Program.cs
|
|
|
|
using Microsoft.AutoGen.Agents;
|
|
using Microsoft.AutoGen.Contracts;
|
|
using Microsoft.AutoGen.Core;
|
|
using Samples;
|
|
|
|
// Set up app builder for in-process runtime, allow message delivery to self, and add the Hello agent
|
|
AgentsAppBuilder appBuilder = new AgentsAppBuilder()
|
|
.UseInProcessRuntime(deliverToSelf: true)
|
|
.AddAgent<HelloAgent>("HelloAgent");
|
|
var app = await appBuilder.BuildAsync(); // Build the app
|
|
// Create a custom message type from proto and define message
|
|
NewMessageReceived message = new NewMessageReceived { Message = "Hello World!" };
|
|
await app.PublishMessageAsync(message, new TopicId("HelloTopic")); // Publish custom message (handler has been set in HelloAgent)
|
|
await app.WaitForShutdownAsync(); // Wait for shutdown from agent
|