0.1.103
This commit is contained in:
		| @@ -1,7 +1,7 @@ | |||||||
| [metadata] | [metadata] | ||||||
| # replace with your username: | # replace with your username: | ||||||
| name = guan | name = guan | ||||||
| version = 0.1.102 | version = 0.1.103 | ||||||
| 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 | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| Metadata-Version: 2.1 | Metadata-Version: 2.1 | ||||||
| Name: guan | Name: guan | ||||||
| Version: 0.1.102 | Version: 0.1.103 | ||||||
| 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 | ||||||
|   | |||||||
| @@ -2,14 +2,10 @@ | |||||||
|  |  | ||||||
| # 模型对话 | # 模型对话 | ||||||
| def chat(prompt='你好', model=1, stream=0, top_p=0.8, temperature=0.85): | def chat(prompt='你好', model=1, stream=0, top_p=0.8, temperature=0.85): | ||||||
|     ''' |  | ||||||
|     model=1: 'qwen1.5-0.5b-chat' |  | ||||||
|     model=2: 'qwen-1.8b-chat' |  | ||||||
|     ''' |  | ||||||
|     import socket |     import socket | ||||||
|     import json |     import json | ||||||
|     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(30) | ||||||
|         client_socket.connect(('socket.guanjihuan.com', 12345)) |         client_socket.connect(('socket.guanjihuan.com', 12345)) | ||||||
|         message = { |         message = { | ||||||
|             'server': "chat.guanjihuan.com", |             'server': "chat.guanjihuan.com", | ||||||
| @@ -25,10 +21,10 @@ 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) | ||||||
|                 stream_response = data.decode() |                 response_data = data.decode() | ||||||
|                 response_dict = json.loads(stream_response) |                 response_dict = json.loads(response_data) | ||||||
|                 stream_response = response_dict['response'] |                 stream_response = response_dict['stream_response'] | ||||||
|                 response = response_dict['all_response'] |                 response = response_dict['response'] | ||||||
|                 end_message = response_dict['end_message'] |                 end_message = response_dict['end_message'] | ||||||
|                 if end_message == 1: |                 if end_message == 1: | ||||||
|                     break |                     break | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user