@inject IRestWrapper RestWrapper @inject ISnackbar Snackbar @foreach (var item in FamilyHistories) { } + افزودن @AiResponse @if (IsProcessing) {

در حال فکر کردن ....

}
@foreach (var item in DrugHistories) {

@item.Question

}
+
@foreach (var item in AhMedicines) {

@item.Question

}
+
@code { private bool IsProcessing { get; set; } private MarkupString AiResponse { get; set; } [Parameter] public string ChiefComplaint { get; set; } = string.Empty; private string _familyHistoryQuestionTitle = string.Empty; private MedicalHistoryQuestionType _familyHistoryQuestionType; [Parameter] public List FamilyHistories { get; set; } = new(); private void RemoveFamilyHistory(MedicalHistoryQuestionSDto question) { FamilyHistories.Remove(question); } private void AddFamilyHistory() { FamilyHistories.Add(new MedicalHistoryQuestionSDto { Question = _familyHistoryQuestionTitle, QuestionType = _familyHistoryQuestionType, Part = MedicalHistoryPart.FamilyHistory }); _familyHistoryQuestionTitle = String.Empty; } private string _drugHistoryName = string.Empty; [Parameter] public List DrugHistories { get; set; } = new(); private void RemoveDrugHistory(MedicalHistoryQuestionSDto medicine) { DrugHistories.Remove(medicine); } private void AddDrugHistory() { DrugHistories.Add(new MedicalHistoryQuestionSDto { Question = _drugHistoryName, QuestionType = MedicalHistoryQuestionType.Selective, Part = MedicalHistoryPart.DrugHistory }); _drugHistoryName = string.Empty; } private string _hhName = string.Empty; [Parameter] public List AhMedicines { get; set; } = new(); private void RemoveHhMedicine(MedicalHistoryQuestionSDto medicine) { AhMedicines.Remove(medicine); } private void AddHhMedicine() { AhMedicines.Add(new MedicalHistoryQuestionSDto { Part = MedicalHistoryPart.AddictionHistory, Question = _hhName, QuestionType = MedicalHistoryQuestionType.Selective }); _hhName = string.Empty; } private async Task AskWithAi() { try { IsProcessing = true; var request = new { content = $"شکایت اصلی بیمار (CC) {ChiefComplaint} است. لطفاً سوالات بخش PI (Present Illness) را در سه دسته زیر تولید کنید: سوالات توضیحی (Open-ended): سوالاتی که بیمار باید توضیح دهد. سوالات بله/خیر (Yes/No): سوالاتی که پاسخ مشخص بله یا خیر دارند. سوالات زمانی (Time-based): سوالاتی مرتبط با زمان شروع، مدت و تغییرات مشکل. لطفاً سوالات مرتبط با سردرد شامل شدت، محل، عوامل تشدیدکننده یا تسکین‌دهنده و علائم همراه (مثل تهوع یا تاری دید) باشد. use html concept for response and just send html and remove , head , html and body tag" }; var response = await RestWrapper.AiRestApi.ChatAsync(request); response = response.Replace("```html", null); response = response.Replace("```", null); response = response.Replace("\\n", null); response = response.Replace(@"""", null); AiResponse = (MarkupString)response; } catch (ApiException ex) { var exe = await ex.GetContentAsAsync(); Snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error); } catch (Exception e) { Snackbar.Add(e.Message, Severity.Error); } finally { IsProcessing = false; } } }