DisplayMessageCommand.cs 1011 B

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