A programming framework for agentic AI
improve subscriptions (#4304)
Ryan Sweet97fd6cc1e091
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/Services/Orleans/SubscriptionsGrain.cs b/dotnet/src/Microsoft.AutoGen/Agents/Services/Orleans/SubscriptionsGrain.csindex 905dc8e91..682073f0b 100644--- a/dotnet/src/Microsoft.AutoGen/Agents/Services/Orleans/SubscriptionsGrain.cs+++ b/dotnet/src/Microsoft.AutoGen/Agents/Services/Orleans/SubscriptionsGrain.cs@@ -6,8 +6,13 @@ namespace Microsoft.AutoGen.Agents;internal sealed class SubscriptionsGrain([PersistentState("state", "PubSubStore")] IPersistentState<SubscriptionsState> state) : Grain, ISubscriptionsGrain{private readonly Dictionary<string, List<string>> _subscriptions = new();- public ValueTask<Dictionary<string, List<string>>> GetSubscriptions(string agentType)+ public ValueTask<Dictionary<string, List<string>>> GetSubscriptions(string? agentType = null){+ //if agentType is null, return all subscriptions else filter on agentType+ if (agentType != null)+ {+ return new ValueTask<Dictionary<string, List<string>>>(_subscriptions.Where(x => x.Value.Contains(agentType)).ToDictionary(x => x.Key, x => x.Value));+ }return new ValueTask<Dictionary<string, List<string>>>(_subscriptions);}public ValueTask Subscribe(string agentType, string topic)