You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 line
2.6KB

  1. @page "/chatroom_llm"
  2. <h3>Chat Room</h3>
  3. @inject ReAct_PME.WebUI.ServicesUI.ApiService ApiService
  4. @using Services;
  5. @using ReAct_PME.WebUI.ServicesUI;
  6. @inject AuthenticationStateProvider AuthenticationStateProvider
  7. @inject NavigationManager Navigation
  8. @inject HttpClient Http
  9. @using Microsoft.AspNetCore.Components.Authorization;
  10. @inject ReAct_PME.WebUI.ServicesUI.AuthService AuthService
  11. <PageTitle>ChatRoom</PageTitle>
  12. <div class="container-fluid">
  13. <div class="container">
  14. <div class="form-group row">
  15. <label for="Question" class="col-sm-2 col-form-label">Question* : </label>
  16. <div class="col-sm-10">
  17. <textarea id="Question" @bind="Question" class="form-control" @oninput="AutoResizeQuestion" rows="3" />
  18. </div>
  19. </div>
  20. <div class="form-group row">
  21. <label for="EnvoiRequete" class="col-sm-2 col-form-label"></label>
  22. <div class="col-sm-10">
  23. <button class="btn-action btn-primary" @onclick="EnvoiRequete">
  24. <i class="bi bi-arrow-clockwise"></i>Envoyer la question
  25. </button>
  26. </div>
  27. </div>
  28. <div class="form-group row">
  29. <label for="Reponse" class="col-sm-2 col-form-label">Reponse : </label>
  30. <div class="col-sm-10">
  31. <textarea id="Reponse" @bind="Reponse" class="form-control" @oninput="AutoResizeReponse" rows="5" disabled />
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. @code {
  37. private string Question = "Quelle a été le premier homme à marcher sur la lune ?";
  38. private string Reponse = string.Empty;
  39. private Guid IdConversationSelected = Guid.Empty;
  40. #region Rendre les zones extensibles
  41. [Inject] IJSRuntime? JS { get; set; }
  42. private void AutoResizeQuestion(ChangeEventArgs e)
  43. {
  44. if (JS != null)
  45. {
  46. JS.InvokeVoidAsync("resizeTextarea", "Question");
  47. }
  48. }
  49. private void AutoResizeReponse(ChangeEventArgs e)
  50. {
  51. if (JS != null)
  52. {
  53. JS.InvokeVoidAsync("resizeTextarea", "Reponse");
  54. }
  55. }
  56. #endregion
  57. protected override async Task OnInitializedAsync()
  58. {
  59. await Task.Delay(1);
  60. }
  61. private async Task EnvoiRequete()
  62. {
  63. try
  64. {
  65. var rep = await ApiService.EnvoiRequete<string>(
  66. "api/ChatRoom/llm", IdConversationSelected.ToString(), AuthService!.ID!,
  67. Question
  68. );
  69. Reponse = rep;
  70. }
  71. catch (Exception ex)
  72. {
  73. Reponse = ex.Message;
  74. }
  75. }
  76. }