This commit is contained in:
guanjihuan 2024-06-07 00:13:13 +08:00
parent e79efc284f
commit c91c34f76b
3 changed files with 13 additions and 12 deletions

View File

@ -1,7 +1,7 @@
[metadata] [metadata]
# replace with your username: # replace with your username:
name = guan name = guan
version = 0.1.105 version = 0.1.106
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.105 Version: 0.1.106
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

@ -22,16 +22,17 @@ def chat(prompt='你好', model=1, stream=0, top_p=0.8, temperature=0.85):
while True: while True:
try: try:
data = client_socket.recv(1024) data = client_socket.recv(1024)
response_data = data.decode() if data != b'':
response_dict = json.loads(response_data) response_data = data.decode()
stream_response = response_dict['stream_response'] response_dict = json.loads(response_data)
response = response_dict['response'] stream_response = response_dict['stream_response']
end_message = response_dict['end_message'] response += stream_response
if end_message == 1: end_message = response_dict['end_message']
break if end_message == 1:
else: break
if stream == 1: else:
print(stream_response) if stream == 1:
print(stream_response)
except: except:
break break
client_socket.close() client_socket.close()