Upload 2 files
Browse filesUpdated GUI for Client
- gui_grad.py +43 -0
- requirements.txt +1 -5
gui_grad.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import socket
|
3 |
+
|
4 |
+
HOST = '129.159.146.88'
|
5 |
+
PORT = 5000
|
6 |
+
|
7 |
+
def sendToServer(message):
|
8 |
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client_socket:
|
9 |
+
client_socket.connect((HOST, PORT))
|
10 |
+
client_socket.sendall(message.encode())
|
11 |
+
# print('Wait...')
|
12 |
+
data = client_socket.recv(1024)
|
13 |
+
try:
|
14 |
+
return data.decode('utf-8')
|
15 |
+
# print(f'Received string from server: {received_string}')
|
16 |
+
except: # sometimes there is a problem with the decoding
|
17 |
+
return "Бот устал и должен отдохнуть"
|
18 |
+
# print('decoding error, please try again')
|
19 |
+
finally:
|
20 |
+
client_socket.close()
|
21 |
+
|
22 |
+
def clear_textbox():
|
23 |
+
return ""
|
24 |
+
|
25 |
+
with gr.Blocks() as WarBot:
|
26 |
+
gr.Markdown(
|
27 |
+
"""
|
28 |
+
# Боевой Чат-Бот портала WarOnline
|
29 |
+
Пока-что это бредогенератор, тренированый на диалогах форума,<br>
|
30 |
+
Есть куча багов. Но мы работаем над улучшениями! :)
|
31 |
+
""")
|
32 |
+
|
33 |
+
with gr.Row():
|
34 |
+
input = gr.Textbox(lines=5, placeholder="Введите сообщение...", label="Вопрос:")
|
35 |
+
output = gr.Textbox(label="Ответ:", lines=5)
|
36 |
+
|
37 |
+
send_btn = gr.Button("Послать Сообщение")
|
38 |
+
send_btn.click(fn=sendToServer, inputs=input, outputs=output)
|
39 |
+
clr_btn = gr.Button("Очистить")
|
40 |
+
clr_btn.click(fn=clear_textbox,outputs=input)
|
41 |
+
|
42 |
+
|
43 |
+
WarBot.launch()
|
requirements.txt
CHANGED
@@ -4,10 +4,6 @@ bs4
|
|
4 |
transformers
|
5 |
scikit-learn
|
6 |
tensorboardX
|
7 |
-
|
8 |
-
autocorrect # spelling
|
9 |
-
normalizer
|
10 |
-
textwrap3 #??
|
11 |
-
# pip install git+https://github.com/RussianNLP/russian_paraphrasers@master
|
12 |
#pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu116
|
13 |
#pip install torch==1.13.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117
|
|
|
4 |
transformers
|
5 |
scikit-learn
|
6 |
tensorboardX
|
7 |
+
gradio
|
|
|
|
|
|
|
|
|
8 |
#pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu116
|
9 |
#pip install torch==1.13.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117
|