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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -27,16 +27,20 @@ def respond(
27
 
28
  # Получение ответа от модели
29
  response = ""
30
- for message in client.chat_completion(
31
- messages,
32
- max_tokens=max_tokens,
33
- stream=True,
34
- temperature=temperature,
35
- top_p=top_p,
36
- ):
37
- token = message.choices[0].delta.content
38
- response += token
39
- yield response
 
 
 
 
40
 
41
  # Выделение диагноза жирным шрифтом
42
  diagnosis_start = response.find("Предварительный диагноз:")
 
27
 
28
  # Получение ответа от модели
29
  response = ""
30
+ try:
31
+ for message in client.chat_completion(
32
+ messages,
33
+ max_tokens=max_tokens,
34
+ stream=True,
35
+ temperature=temperature,
36
+ top_p=top_p,
37
+ ):
38
+ token = message.choices[0].delta.content
39
+ response += token
40
+ yield response
41
+ except Exception as e:
42
+ print(f"Error occurred during message generation: {e}")
43
+ yield "Произошла ошибка при обработке запроса."
44
 
45
  # Выделение диагноза жирным шрифтом
46
  diagnosis_start = response.find("Предварительный диагноз:")