Xolkin commited on
Commit
87d732e
·
verified ·
1 Parent(s): dc0ecdd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -21
app.py CHANGED
@@ -24,28 +24,28 @@ def respond(
24
 
25
  messages.append({"role": "user", "content": message})
26
 
27
- response = ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
- for message in client.chat_completion(
30
- messages,
31
- max_tokens=max_tokens,
32
- stream=True,
33
- temperature=temperature,
34
- top_p=top_p,
35
- ):
36
- token = message.choices[0].delta.content
37
- response += token
38
-
39
- # Добавьте логику для обработки медицинских запросов
40
- if "диагноз" in message.lower() or "операция" in message.lower():
41
- response += "\n\nПредварительный диагноз: [Ваш диагноз]\n"
42
- response += "Операция: [Требуется ли операция и какая]\n"
43
- response += "Уточняющие вопросы для постановки диагноза:\n"
44
- response += "- Вопрос 1\n"
45
- response += "- Вопрос 2\n"
46
- response += "- Вопрос 3\n"
47
-
48
- yield response
49
 
50
  """
51
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
 
24
 
25
  messages.append({"role": "user", "content": message})
26
 
27
+ # Check if the message is a greeting or a request for medical information
28
+ if message.lower() in ["привет", "здравствуйте", "hello", "hi"]:
29
+ response = "Привет! Как я могу помочь вам сегодня?"
30
+ elif "предварительный диагноз" in message.lower() or "операция" in message.lower():
31
+ response = (
32
+ "Каков предварительный диагноз? Какая операция требуется (если требуется)? "
33
+ "Уточняющие вопросы для постановки диагноза (если требуется бот)."
34
+ )
35
+ else:
36
+ response = ""
37
+ for message in client.chat_completion(
38
+ messages,
39
+ max_tokens=max_tokens,
40
+ stream=True,
41
+ temperature=temperature,
42
+ top_p=top_p,
43
+ ):
44
+ token = message.choices[0].delta.content
45
+ response += token
46
+ yield response
47
 
48
+ yield response
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
  """
51
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface