Update app.py
Browse files
app.py
CHANGED
@@ -2,9 +2,7 @@ import os
|
|
2 |
import random
|
3 |
from typing import List, Tuple, Union
|
4 |
from gradio_client import Client
|
5 |
-
|
6 |
-
# Устанавливаем необходимые библиотеки
|
7 |
-
os.system("pip install gradio_client")
|
8 |
|
9 |
# Получаем список ключей из переменной окружения
|
10 |
api_keys = os.getenv("KEYS", "").split(",")
|
@@ -47,8 +45,6 @@ def flushed() -> dict:
|
|
47 |
|
48 |
# Основная функция приложения
|
49 |
def app_gui():
|
50 |
-
import gradio as gr
|
51 |
-
|
52 |
def chat(message, chat_history):
|
53 |
# Добавляем текст в чат
|
54 |
_input = {"files": [], "text": message}
|
@@ -64,14 +60,16 @@ def app_gui():
|
|
64 |
# Создаем интерфейс Gradio
|
65 |
with gr.Blocks() as demo:
|
66 |
chatbot = gr.Chatbot(label="Chatbot")
|
67 |
-
|
68 |
-
|
|
|
69 |
|
|
|
70 |
msg.submit(chat, [msg, chatbot], [msg, chatbot])
|
|
|
71 |
clear.click(clear_chat, None, chatbot)
|
72 |
|
73 |
demo.launch()
|
74 |
|
75 |
if __name__ == '__main__':
|
76 |
app_gui()
|
77 |
-
|
|
|
2 |
import random
|
3 |
from typing import List, Tuple, Union
|
4 |
from gradio_client import Client
|
5 |
+
import gradio as gr
|
|
|
|
|
6 |
|
7 |
# Получаем список ключей из переменной окружения
|
8 |
api_keys = os.getenv("KEYS", "").split(",")
|
|
|
45 |
|
46 |
# Основная функция приложения
|
47 |
def app_gui():
|
|
|
|
|
48 |
def chat(message, chat_history):
|
49 |
# Добавляем текст в чат
|
50 |
_input = {"files": [], "text": message}
|
|
|
60 |
# Создаем интерфейс Gradio
|
61 |
with gr.Blocks() as demo:
|
62 |
chatbot = gr.Chatbot(label="Chatbot")
|
63 |
+
with gr.Row():
|
64 |
+
msg = gr.Textbox(label="Message")
|
65 |
+
btn = gr.Button("Send")
|
66 |
|
67 |
+
btn.click(chat, [msg, chatbot], [msg, chatbot])
|
68 |
msg.submit(chat, [msg, chatbot], [msg, chatbot])
|
69 |
+
clear = gr.Button("Clear")
|
70 |
clear.click(clear_chat, None, chatbot)
|
71 |
|
72 |
demo.launch()
|
73 |
|
74 |
if __name__ == '__main__':
|
75 |
app_gui()
|
|