DisplayMessageCommand.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using UnityEngine;
  2. using LLM.Editor.Data;
  3. using LLM.Editor.Helper;
  4. using JetBrains.Annotations;
  5. namespace LLM.Editor.Commands
  6. {
  7. // Parameters for this command
  8. [System.Serializable]
  9. public class DisplayMessageParams
  10. {
  11. public string message;
  12. }
  13. [UsedImplicitly]
  14. public class DisplayMessageCommand : ICommand
  15. {
  16. private readonly DisplayMessageParams _params;
  17. public DisplayMessageCommand(string jsonParams)
  18. {
  19. _params = jsonParams?.FromJson<DisplayMessageParams>();
  20. }
  21. public void Execute(CommandContext context)
  22. {
  23. if (_params == null || string.IsNullOrEmpty(_params.message))
  24. {
  25. Debug.LogError("[DisplayMessageCommand] Parameters are invalid or message is empty.");
  26. return;
  27. }
  28. // In a real UI, this would render to the chat window.
  29. // For now, we just log it.
  30. Debug.Log($"[LLM RESPONSE]: {_params.message}");
  31. }
  32. }
  33. }