Update app.py
Browse files
app.py
CHANGED
@@ -27,16 +27,20 @@ def respond(
|
|
27 |
|
28 |
# Получение ответа от модели
|
29 |
response = ""
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
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("Предварительный диагноз:")
|