File size: 827 Bytes
ddf7ac7 17e09e4 ddf7ac7 17e09e4 ddf7ac7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import socket
import WarBot
import warnings
warnings.filterwarnings("ignore")
model,tokenizer,model_punct = WarBot.initialize()
HOST = '10.0.0.125'
PORT = 5000
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as server_socket:
server_socket.bind((HOST, PORT))
server_socket.listen()
print(f'Server is listening on port {PORT}')
while True:
conn, addr = server_socket.accept()
with conn:
print(f'Connected by {addr}')
data = conn.recv(1024)
received_string = data.decode()
print(f'Received string from client: {received_string}')
response = WarBot.get_response(received_string, model, tokenizer, model_punct)
response_string = response
conn.sendall(response_string.encode())
conn.close()
|