Xolkin commited on
Commit
e36d9ee
·
verified ·
1 Parent(s): 8deaf06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -2
app.py CHANGED
@@ -42,7 +42,11 @@ def respond(
42
  print(f"Error occurred during message generation: {e}")
43
  yield "Произошла ошибка при обработке запроса."
44
 
45
- # Выделение диагноза жирным шрифтом
 
 
 
 
46
  diagnosis_start = response.find("Предварительный диагноз:")
47
  if diagnosis_start != -1:
48
  diagnosis_end = response.find("\n", diagnosis_start)
@@ -51,7 +55,25 @@ def respond(
51
  diagnosis = response[diagnosis_start:diagnosis_end]
52
  response = response[:diagnosis_start] + f"<b>{diagnosis}</b>" + response[diagnosis_end:]
53
 
54
- # Добавление идентификационного сообщения к ответу
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  final_response = f"{response}\n\nСоздано больницей EMS штата Alta"
56
  yield final_response
57
 
 
42
  print(f"Error occurred during message generation: {e}")
43
  yield "Произошла ошибка при обработке запроса."
44
 
45
+ # Формирование ответа в нужном формате
46
+ # Пример ответа: "Предварительный диагноз: Грипп\nОперация: Не требуется\nУточняющие вопросы: Как давно начались симптомы?"
47
+ response = response.strip()
48
+
49
+ # Обработка предварительного диагноза
50
  diagnosis_start = response.find("Предварительный диагноз:")
51
  if diagnosis_start != -1:
52
  diagnosis_end = response.find("\n", diagnosis_start)
 
55
  diagnosis = response[diagnosis_start:diagnosis_end]
56
  response = response[:diagnosis_start] + f"<b>{diagnosis}</b>" + response[diagnosis_end:]
57
 
58
+ # Операция
59
+ operation_start = response.find("Операция:")
60
+ if operation_start != -1:
61
+ operation_end = response.find("\n", operation_start)
62
+ if operation_end == -1:
63
+ operation_end = len(response)
64
+ operation = response[operation_start:operation_end]
65
+ response = response[:operation_start] + f"<b>{operation}</b>" + response[operation_end:]
66
+
67
+ # Уточняющие вопросы
68
+ questions_start = response.find("Уточняющие вопросы:")
69
+ if questions_start != -1:
70
+ questions_end = response.find("\n", questions_start)
71
+ if questions_end == -1:
72
+ questions_end = len(response)
73
+ questions = response[questions_start:questions_end]
74
+ response = response[:questions_start] + f"<b>{questions}</b>" + response[questions_end:]
75
+
76
+ # Формирование финального ответа с добавлением идентификационного сообщения
77
  final_response = f"{response}\n\nСоздано больницей EMS штата Alta"
78
  yield final_response
79