Skip to content

Commit

Permalink
back AgentsApp off of ASPNET
Browse files Browse the repository at this point in the history
  • Loading branch information
rysweet committed Jan 17, 2025
1 parent 6215c5d commit 7093034
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions dotnet/src/Microsoft.AutoGen/Core/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using Google.Protobuf;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
Expand All @@ -13,27 +12,25 @@ namespace Microsoft.AutoGen.Core;
public static class AgentsApp
{
// need a variable to store the runtime instance
public static WebApplication? Host { get; private set; }
public static IHost? Host { get; private set; }

[MemberNotNull(nameof(Host))]
public static async ValueTask<WebApplication> StartAsync(WebApplicationBuilder? builder = null, AgentTypes? agentTypes = null)
public static async ValueTask<IHost> StartAsync(HostApplicationBuilder? builder = null, AgentTypes? agentTypes = null)
{
builder ??= WebApplication.CreateBuilder();
builder ??= new HostApplicationBuilder();
builder.Services.TryAddSingleton(DistributedContextPropagator.Current);
builder.AddAgentWorker()
.AddAgents(agentTypes);
builder.AddServiceDefaults();
var app = builder.Build();

app.MapDefaultEndpoints();
Host = app;
await app.StartAsync().ConfigureAwait(false);
return Host;
}
public static async ValueTask<WebApplication> PublishMessageAsync(
public static async ValueTask<IHost> PublishMessageAsync(
string topic,
IMessage message,
WebApplicationBuilder? builder = null,
HostApplicationBuilder? builder = null,
AgentTypes? agents = null,
bool local = false)
{
Expand Down

0 comments on commit 7093034

Please sign in to comment.