| | | 1 | | namespace NexusLabs.Needlr.AgentFramework; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Assigns a class to a named function group so that it can be wired to agents by group name |
| | | 5 | | /// rather than by explicit type reference. |
| | | 6 | | /// </summary> |
| | | 7 | | /// <remarks> |
| | | 8 | | /// Apply this attribute to classes that contain methods decorated with |
| | | 9 | | /// <see cref="AgentFunctionAttribute"/>. Register groups using |
| | | 10 | | /// <c>AddAgentFunctionGroupsFromAssemblies()</c> or <c>AddAgentFunctionGroupsFromGenerated()</c>, |
| | | 11 | | /// then reference them in <see cref="AgentFactoryOptions.FunctionGroups"/> at agent creation time. |
| | | 12 | | /// <para> |
| | | 13 | | /// A class may belong to multiple groups by applying this attribute more than once. |
| | | 14 | | /// </para> |
| | | 15 | | /// </remarks> |
| | | 16 | | /// <example> |
| | | 17 | | /// <code> |
| | | 18 | | /// [AgentFunctionGroup("research")] |
| | | 19 | | /// public class GeographyFunctions { ... } |
| | | 20 | | /// |
| | | 21 | | /// [AgentFunctionGroup("research")] |
| | | 22 | | /// [AgentFunctionGroup("general")] |
| | | 23 | | /// public class FactFunctions { ... } |
| | | 24 | | /// |
| | | 25 | | /// // At agent creation: |
| | | 26 | | /// agentFactory.CreateAgent(opts => opts.FunctionGroups = ["research"]); |
| | | 27 | | /// </code> |
| | | 28 | | /// </example> |
| | | 29 | | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)] |
| | | 30 | | public sealed class AgentFunctionGroupAttribute : Attribute |
| | | 31 | | { |
| | | 32 | | /// <summary> |
| | | 33 | | /// Initializes a new instance of <see cref="AgentFunctionGroupAttribute"/>. |
| | | 34 | | /// </summary> |
| | | 35 | | /// <param name="groupName">The name of the group this class belongs to.</param> |
| | 1396 | 36 | | public AgentFunctionGroupAttribute(string groupName) |
| | | 37 | | { |
| | 1396 | 38 | | ArgumentException.ThrowIfNullOrWhiteSpace(groupName); |
| | 1393 | 39 | | GroupName = groupName; |
| | 1393 | 40 | | } |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// Gets the name of the group this class belongs to. |
| | | 44 | | /// </summary> |
| | 173 | 45 | | public string GroupName { get; } |
| | | 46 | | } |