Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -10,13 +10,16 @@ css_url = "https://neurixyufi-aihub.static.hf.space/style.css"
|
|
10 |
try:
|
11 |
response = requests.get(css_url)
|
12 |
response.raise_for_status() # Поднимаем исключение, если статус ответа не 200
|
13 |
-
css = response.text + " h1{text-align:center}
|
14 |
except requests.exceptions.RequestException as e:
|
15 |
print(f"Ошибка при загрузке CSS: {e}")
|
16 |
-
css = " h1{text-align:center}
|
17 |
|
18 |
# Функция для отправки запроса к API searchgpt
|
19 |
-
def chat_with_searchgpt(user_message, history):
|
|
|
|
|
|
|
20 |
api_url = "https://text.pollinations.ai/openai"
|
21 |
headers = {
|
22 |
"Content-Type": "application/json"
|
@@ -48,18 +51,23 @@ def chat_with_searchgpt(user_message, history):
|
|
48 |
|
49 |
# Определение интерфейса
|
50 |
with gr.Blocks(css=css) as demo:
|
51 |
-
gr.Markdown("#
|
52 |
-
chatbot = gr.Chatbot(label="Чат")
|
53 |
-
msg = gr.Textbox(label="Введите ваш
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
# Функция для очистки чата
|
57 |
def clear_chat():
|
58 |
return [], ""
|
59 |
|
60 |
# Обработка отправки сообщения
|
61 |
-
msg.submit(chat_with_searchgpt, [msg, chatbot], [chatbot, msg], concurrency_limit=250)
|
62 |
-
|
63 |
|
64 |
# Запуск интерфейса
|
65 |
demo.launch(show_api=False, share=False)
|
|
|
10 |
try:
|
11 |
response = requests.get(css_url)
|
12 |
response.raise_for_status() # Поднимаем исключение, если статус ответа не 200
|
13 |
+
css = response.text + " h1{text-align:center} #component-2 { height: 70vh !important; }"
|
14 |
except requests.exceptions.RequestException as e:
|
15 |
print(f"Ошибка при загрузке CSS: {e}")
|
16 |
+
css = " h1{text-align:center} #component-2 { height: 70vh !important; }" # Используем базовый стиль, если загрузка CSS не удалась
|
17 |
|
18 |
# Функция для отправки запроса к API searchgpt
|
19 |
+
def chat_with_searchgpt(user_message="", history=[], max_tokens=2500, temperature=0.7, top_p=0.95):
|
20 |
+
if user_message == "":
|
21 |
+
return history, user_message
|
22 |
+
|
23 |
api_url = "https://text.pollinations.ai/openai"
|
24 |
headers = {
|
25 |
"Content-Type": "application/json"
|
|
|
51 |
|
52 |
# Определение интерфейса
|
53 |
with gr.Blocks(css=css) as demo:
|
54 |
+
gr.Markdown("# Ии поиск")
|
55 |
+
chatbot = gr.Chatbot(label="Чат", show_share_button=False)
|
56 |
+
msg = gr.Textbox(label="Введите ваш запрос...")
|
57 |
+
send = gr.Button("Отправить", variant="primary")
|
58 |
+
|
59 |
+
with gr.Accordion("Настройки помощника", open=False):
|
60 |
+
max_tokens = gr.Slider(minimum=100, maximum=20000, value=2500, step=1, label="Максимальное количество новых токенов")
|
61 |
+
temperature = gr.Slider(minimum=0.0, maximum=1.0, value=0.7, step=0.1, label="Температура")
|
62 |
+
top_p = gr.Slider(minimum=0.0, maximum=1.0, value=0.95, step=0.05, label="Top-p (нуклеарное сэмплирование)")
|
63 |
|
64 |
# Функция для очистки чата
|
65 |
def clear_chat():
|
66 |
return [], ""
|
67 |
|
68 |
# Обработка отправки сообщения
|
69 |
+
msg.submit(chat_with_searchgpt, [msg, chatbot, max_tokens, temperature, top_p], [chatbot, msg], concurrency_limit=250)
|
70 |
+
click.click(chat_with_searchgpt, [msg, chatbot, max_tokens, temperature, top_p], [chatbot, msg], concurrency_limit=250)
|
71 |
|
72 |
# Запуск интерфейса
|
73 |
demo.launch(show_api=False, share=False)
|