Delete gui_grad.py
Browse files- gui_grad.py +0 -43
gui_grad.py
DELETED
@@ -1,43 +0,0 @@
|
|
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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|