Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -17,6 +17,7 @@ import string
|
|
17 |
import io
|
18 |
from datetime import datetime, timedelta
|
19 |
import plotly.express as px
|
|
|
20 |
|
21 |
morph = pymorphy2.MorphAnalyzer()
|
22 |
|
@@ -32,7 +33,8 @@ client = Together(api_key=TOGETHER_API_KEY)
|
|
32 |
# Авторизация в сервисе GigaChat
|
33 |
chat_pro = GigaChat(credentials=gc_key, model='GigaChat-Pro', max_tokens=68, temperature=1, verify_ssl_certs=False)
|
34 |
chat_lite = GigaChat(credentials=gc_key, model='GigaChat', max_tokens=68, temperature=1.15, verify_ssl_certs=False)
|
35 |
-
chat_plus = GigaChat(credentials=gc_key, model='GigaChat-Plus', max_tokens=68, temperature=1.15, verify_ssl_certs=False)
|
|
|
36 |
|
37 |
# Загрузка данных из Excel-файла
|
38 |
try:
|
@@ -1056,15 +1058,27 @@ def generate_message_gigachat_lite(prompt):
|
|
1056 |
except Exception as e:
|
1057 |
return f"Ошибка при обращении к GigaChat-Lite: {e}"
|
1058 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1059 |
def generate_message_gigachat_plus(prompt):
|
1060 |
try:
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
|
|
1065 |
return cleaned_message
|
1066 |
except Exception as e:
|
1067 |
-
return f"Ошибка при обращении к
|
|
|
1068 |
|
1069 |
def generate_message_meta_llama_3_1_405b(prompt):
|
1070 |
try:
|
@@ -1469,34 +1483,6 @@ def personalize_and_save(
|
|
1469 |
|
1470 |
save_user_request_to_github(description, advantages, key_message, approach, selected_values)
|
1471 |
|
1472 |
-
|
1473 |
-
def clear_fields():
|
1474 |
-
return (
|
1475 |
-
"", "", "", "", "", # personalized outputs and prompts
|
1476 |
-
"", "", "", "", "", # comment fields
|
1477 |
-
"", "", "", "", "", # corrected message fields
|
1478 |
-
"", "", "", "", "", # анализ персонализации
|
1479 |
-
)
|
1480 |
-
|
1481 |
-
|
1482 |
-
def clear_personalization_fields():
|
1483 |
-
return (
|
1484 |
-
"", "", "", "", "", # personalized outputs
|
1485 |
-
"", "", "", "", "", # comment fields
|
1486 |
-
"", "", "", "", "", # corrected message fields
|
1487 |
-
"", "", "", "", "", # анализ персонализации
|
1488 |
-
""
|
1489 |
-
)
|
1490 |
-
|
1491 |
-
def clear_on_change():
|
1492 |
-
return (
|
1493 |
-
"", "", "", "", "", # очистка всех полей для промптов и сообщений
|
1494 |
-
"", "", "", "", "", # комментарии
|
1495 |
-
"", "", "", "", "", # откорректированные сообщения
|
1496 |
-
"", "", "", "", "", # результаты проверок
|
1497 |
-
"", "", "", "", "",
|
1498 |
-
)
|
1499 |
-
|
1500 |
def clear_on_change_pers():
|
1501 |
return (
|
1502 |
"", "", "", "", "", # очистка всех полей для промптов и сообщений
|
@@ -1505,15 +1491,6 @@ def clear_on_change_pers():
|
|
1505 |
"", "", "", "", "" # результаты проверок
|
1506 |
)
|
1507 |
|
1508 |
-
def clear_unnecessary_fields():
|
1509 |
-
return (
|
1510 |
-
"", "", "", "", "", # personalized outputs and prompts
|
1511 |
-
"", "", "", "", "", # comment fields
|
1512 |
-
"", "", "", "", "", # corrected message fields
|
1513 |
-
"", "", "", "", "", # оставшиеся поля
|
1514 |
-
"", "", # Дополнительное пустое значение
|
1515 |
-
"", "", "", "", "", # поля анализа персонализации
|
1516 |
-
)
|
1517 |
|
1518 |
def clear_outputs(*args):
|
1519 |
return ('',) * len(args)
|
|
|
17 |
import io
|
18 |
from datetime import datetime, timedelta
|
19 |
import plotly.express as px
|
20 |
+
from gradio_client import Client
|
21 |
|
22 |
morph = pymorphy2.MorphAnalyzer()
|
23 |
|
|
|
33 |
# Авторизация в сервисе GigaChat
|
34 |
chat_pro = GigaChat(credentials=gc_key, model='GigaChat-Pro', max_tokens=68, temperature=1, verify_ssl_certs=False)
|
35 |
chat_lite = GigaChat(credentials=gc_key, model='GigaChat', max_tokens=68, temperature=1.15, verify_ssl_certs=False)
|
36 |
+
# chat_plus = GigaChat(credentials=gc_key, model='GigaChat-Plus', max_tokens=68, temperature=1.15, verify_ssl_certs=False)
|
37 |
+
client_vikhr = Client("https://6429e2570d3517d2f7.gradio.live/")
|
38 |
|
39 |
# Загрузка данных из Excel-файла
|
40 |
try:
|
|
|
1058 |
except Exception as e:
|
1059 |
return f"Ошибка при обращении к GigaChat-Lite: {e}"
|
1060 |
|
1061 |
+
#def generate_message_gigachat_plus(prompt):
|
1062 |
+
# try:
|
1063 |
+
# time.sleep(2)
|
1064 |
+
# messages = [SystemMessage(content=prompt)]
|
1065 |
+
# res = chat_plus(messages)
|
1066 |
+
# cleaned_message = clean_message(res.content.strip())
|
1067 |
+
# return cleaned_message
|
1068 |
+
# except Exception as e:
|
1069 |
+
# return f"Ошибка при обращении к GigaChat-Plus: {e}"
|
1070 |
+
|
1071 |
def generate_message_gigachat_plus(prompt):
|
1072 |
try:
|
1073 |
+
result = client_vikhr.predict(
|
1074 |
+
message=prompt,
|
1075 |
+
api_name="/chat"
|
1076 |
+
)
|
1077 |
+
cleaned_message = clean_message(result.strip())
|
1078 |
return cleaned_message
|
1079 |
except Exception as e:
|
1080 |
+
return f"Ошибка при обращении к Vikhr-Nemo-12B: {e}"
|
1081 |
+
|
1082 |
|
1083 |
def generate_message_meta_llama_3_1_405b(prompt):
|
1084 |
try:
|
|
|
1483 |
|
1484 |
save_user_request_to_github(description, advantages, key_message, approach, selected_values)
|
1485 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1486 |
def clear_on_change_pers():
|
1487 |
return (
|
1488 |
"", "", "", "", "", # очистка всех полей для промптов и сообщений
|
|
|
1491 |
"", "", "", "", "" # результаты проверок
|
1492 |
)
|
1493 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1494 |
|
1495 |
def clear_outputs(*args):
|
1496 |
return ('',) * len(args)
|