using System.Reflection; using Microsoft.Extensions.AI; namespace Luna.Core.Tools; public interface IToolbox { public string Name { get; } public sealed IEnumerable GetTools() { var type = GetType(); List<(ToolAttribute Attribute, MethodInfo Method)> tools = []; foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Instance)) { var attribute = method.GetCustomAttribute(); if (attribute is null) continue; tools.Add((attribute, method)); } return tools.Select(tool => AIFunctionFactory.Create( tool.Method, this, $"{this.Name}/{tool.Attribute.Name}", tool.Attribute.Description )); } }