diff --git a/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/Termination.cs b/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/Termination.cs index 47f2cc821356..f5cb00cfe979 100644 --- a/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/Termination.cs +++ b/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/Termination.cs @@ -4,7 +4,7 @@ namespace Microsoft.AutoGen.AgentChat.Abstractions; /// -/// A stateful condition that deterines when a conversation should be terminated. +/// A stateful condition that determines when a conversation should be terminated. /// /// A termination condition takes a sequences of objects since the last time the /// condition was checked, and returns a if the conversation should be terminated, @@ -17,7 +17,7 @@ namespace Microsoft.AutoGen.AgentChat.Abstractions; public interface ITerminationCondition { /// - /// Checkes if the termination condition has been reached + /// Checks if the termination condition has been reached /// bool IsTerminated { get; } @@ -86,19 +86,19 @@ internal sealed class CombinerCondition : ITerminationCondition /// /// Create a new with the given conjunction and clauses. /// - /// The conjunction to use when combining the clauses. + /// The conjunction to use when combining the clauses. /// The termination conditions to combine. - public CombinerCondition(bool conjuction, params IEnumerable clauses) + public CombinerCondition(bool conjunction, params IEnumerable clauses) { // Flatten the list of clauses by unwrapping included CombinerConditions if their - // conjuctions match (since combiners with associative conjuctions can be hoisted). + // conjunctions match (since combiners with associative conjunctions can be hoisted). IEnumerable flattened = clauses.SelectMany(c => - (c is CombinerCondition combiner && combiner.conjunction == conjuction) + (c is CombinerCondition combiner && combiner.conjunction == conjunction) ? (IEnumerable)combiner.clauses : new[] { c }); - this.conjunction = conjuction; + this.conjunction = conjunction; this.clauses = flattened.ToList(); } @@ -106,7 +106,7 @@ public CombinerCondition(bool conjuction, params IEnumerable public bool IsTerminated { get; private set; } - /// "/> + /// public void Reset() { this.stopMessages.Clear(); @@ -149,7 +149,7 @@ public void Reset() } else if (this.conjunction) { - // If any clause does not terminate, the conjuction does not terminate + // If any clause does not terminate, the conjunction does not terminate raiseTermination = false; } } diff --git a/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatBase.cs b/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatBase.cs index bfc2faa1b422..5192cac6d086 100644 --- a/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatBase.cs +++ b/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatBase.cs @@ -93,7 +93,7 @@ protected GroupChatBase(List participants, ITerminationCondition? te { AgentChatConfig config = new AgentChatConfig(participant, GroupTopicType, OutputTopicType); this.Participants[participant.Name] = config; - this.GroupChatOptions.Participants[participant.Name] = (config.ParticipantTopicType, participant.Description); + this.GroupChatOptions.Participants[participant.Name] = new GroupParticipant(config.ParticipantTopicType, participant.Description); } this.messageThread = new List(); // TODO: Allow injecting this diff --git a/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatManagerBase.cs b/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatManagerBase.cs index ecd1130fe516..69c57e344d89 100644 --- a/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatManagerBase.cs +++ b/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatManagerBase.cs @@ -28,7 +28,7 @@ public GroupChatManagerBase(GroupChatOptions options) : base() protected string GroupChatTopicType => this.options.GroupChatTopicType; protected string OutputTopicType => this.options.OutputTopicType; - protected Dictionary Participants => this.options.Participants; + protected Dictionary Participants => this.options.Participants; protected ITerminationCondition? TerminationCondition => this.options.TerminationCondition; protected int? MaxTurns => this.options.MaxTurns; diff --git a/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatOptions.cs b/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatOptions.cs index 58ba1b428131..e0907e5231c7 100644 --- a/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatOptions.cs +++ b/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatOptions.cs @@ -5,6 +5,27 @@ namespace Microsoft.AutoGen.AgentChat.GroupChat; +public struct GroupParticipant(string topicType, string description) +{ + public string TopicType { get; } = topicType; + public string Description { get; } = description; + + // Destructuring from a tuple + public GroupParticipant((string topicType, string description) tuple) : this(tuple.topicType, tuple.description) + { + } + + // Destructuring to a tuple + public void Deconstruct(out string topicType, out string description) + { + topicType = this.TopicType; + description = this.Description; + } + + public static implicit operator GroupParticipant((string topicType, string description) tuple) => new GroupParticipant(tuple); + public static implicit operator (string topicType, string description)(GroupParticipant participant) => (participant.TopicType, participant.Description); +} + public class GroupChatOptions(string groupTopicType, string outputTopicType) { public string GroupChatTopicType { get; } = groupTopicType; @@ -13,5 +34,5 @@ public class GroupChatOptions(string groupTopicType, string outputTopicType) public ITerminationCondition? TerminationCondition { get; set; } public int? MaxTurns { get; set; } - public Dictionary Participants { get; } = new Dictionary(); + public Dictionary Participants { get; } = new Dictionary(); }