ContextProviderRegistry.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3. namespace LLM.Editor.Analysis
  4. {
  5. /// <summary>
  6. /// A static registry that holds all the available "tools" (Context Providers)
  7. /// that the LLM can use to query the project.
  8. /// </summary>
  9. public static class ContextProviderRegistry
  10. {
  11. private static readonly Dictionary<string, IContextProvider> _providers = new();
  12. // This static constructor will be used in the next phase to register all our tools.
  13. static ContextProviderRegistry()
  14. {
  15. RegisterProvider("ComponentData", new ComponentDataProvider());
  16. RegisterProvider("SourceCode", new SourceCodeProvider());
  17. RegisterProvider("ProjectSettings", new ProjectSettingsProvider());
  18. RegisterProvider("FindAssets", new FindAssetsProvider());
  19. RegisterProvider("FindInScene", new FindInSceneProvider());
  20. RegisterProvider("ConsoleLog", new ConsoleLogProvider());
  21. }
  22. private static void RegisterProvider(string dataType, IContextProvider provider)
  23. {
  24. if (string.IsNullOrEmpty(dataType) || provider == null) return;
  25. _providers[dataType] = provider;
  26. }
  27. public static IContextProvider GetProvider(string dataType)
  28. {
  29. _providers.TryGetValue(dataType, out var provider);
  30. return provider;
  31. }
  32. }
  33. }