mirror of
https://github.com/microsoft/autogen.git
synced 2026-01-23 00:28:02 -05:00
add subscriptions to host builder
This commit is contained in:
committed by
Jack Gerrits
parent
fe8faa9133
commit
2ba7732220
@@ -69,7 +69,7 @@ public static class AgentRuntimeExtensions
|
||||
return subscriptions.ToArray();
|
||||
}
|
||||
|
||||
public static async ValueTask RegisterImplicitAgentSubscriptionsAsync<TAgent>(this IAgentRuntime runtime, AgentType type) where TAgent : IHostableAgent
|
||||
public static async ValueTask RegisterImplicitAgentSubscriptionsAsync<TAgent>(this IAgentRuntime runtime, AgentType type, bool skipClassSubscriptions = false, bool skipDirectMessageSubscription = false) where TAgent : IHostableAgent
|
||||
{
|
||||
var subscriptions = BindSubscriptionsForAgentType<TAgent>(type);
|
||||
foreach (var subscription in subscriptions)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// App.cs
|
||||
// AgentsApp.cs
|
||||
|
||||
using Microsoft.AutoGen.Contracts.Python;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -18,13 +18,13 @@ public class AgentsAppBuilder
|
||||
this.builder = baseBuilder ?? new HostApplicationBuilder();
|
||||
}
|
||||
|
||||
public void AddAgent<TAgent>(string name, bool registerDefaultTopics = true) where TAgent : IHostableAgent
|
||||
public void AddAgent<TAgent>(string name, bool skipClassSubscriptions = false, bool skipDirectMessageSubscription = false) where TAgent : IHostableAgent
|
||||
{
|
||||
this.AgentTypeRegistrations.Add(app => app.AgentRuntime.RegisterAgentTypeAsync<TAgent>(name, app.Services));
|
||||
if (registerDefaultTopics)
|
||||
{
|
||||
//TODO: this.AgentTypeRegistrations.Add(app => app.AgentRuntime.RegisterDefaultTopicsAsync<TAgent>(name));
|
||||
}
|
||||
this.AgentTypeRegistrations.Add(async app => {
|
||||
var agentType = await app.AgentRuntime.RegisterAgentTypeAsync<TAgent>(name, app.Services);
|
||||
await app.AgentRuntime.RegisterImplicitAgentSubscriptionsAsync<TAgent>(name, skipClassSubscriptions, skipDirectMessageSubscription);
|
||||
return agentType;
|
||||
});
|
||||
}
|
||||
|
||||
public async ValueTask<AgentsApp> BuildAsync()
|
||||
|
||||
Reference in New Issue
Block a user