This commit is contained in:
guanjihuan 2023-11-17 04:24:11 +08:00
parent 1f536d080d
commit 9f012a9564
3 changed files with 29 additions and 38 deletions

View File

@ -1,7 +1,7 @@
[metadata] [metadata]
# replace with your username: # replace with your username:
name = guan name = guan
version = 0.1.32 version = 0.1.33
author = guanjihuan author = guanjihuan
author_email = guanjihuan@163.com author_email = guanjihuan@163.com
description = An open source python package description = An open source python package

View File

@ -1,6 +1,6 @@
Metadata-Version: 2.1 Metadata-Version: 2.1
Name: guan Name: guan
Version: 0.1.32 Version: 0.1.33
Summary: An open source python package Summary: An open source python package
Home-page: https://py.guanjihuan.com Home-page: https://py.guanjihuan.com
Author: guanjihuan Author: guanjihuan

View File

@ -389,7 +389,6 @@ def chat(prompt='你好', stream_show=1, top_p=0.8, temperature=0.8):
import socket import socket
import json import json
response = '' response = ''
try:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client_socket: with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client_socket:
client_socket.settimeout(15) client_socket.settimeout(15)
client_socket.connect(('socket.guanjihuan.com', 12345)) client_socket.connect(('socket.guanjihuan.com', 12345))
@ -401,17 +400,13 @@ def chat(prompt='你好', stream_show=1, top_p=0.8, temperature=0.8):
} }
send_message = json.dumps(message) send_message = json.dumps(message)
client_socket.send(send_message.encode()) client_socket.send(send_message.encode())
try:
while True: while True:
try:
data = client_socket.recv(1024) data = client_socket.recv(1024)
except:
break
stream_response = data.decode() stream_response = data.decode()
if '连接失败!请过段时间再试或者联系管理员。' in stream_response: response_dict = json.loads(stream_response)
print('连接失败!请过段时间再试或者联系管理员。') stream_response = response_dict['response']
break end_message = response_dict['end_message']
elif 'End_response_from_chat.guanjihuan.com.' in stream_response: if end_message == 1:
break break
elif stream_response == '': elif stream_response == '':
break break
@ -420,11 +415,7 @@ def chat(prompt='你好', stream_show=1, top_p=0.8, temperature=0.8):
print(stream_response) print(stream_response)
print('\n---\n') print('\n---\n')
response = stream_response response = stream_response
except:
pass
client_socket.close() client_socket.close()
except:
print('连接失败!请过段时间再试或者联系管理员。')
import guan import guan
guan.statistics_of_guan_package() guan.statistics_of_guan_package()
return response return response