0.1.148
This commit is contained in:
parent
78898443c3
commit
5c055bfe8b
@ -1,7 +1,7 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
# replace with your username:
|
# replace with your username:
|
||||||
name = guan
|
name = guan
|
||||||
version = 0.1.147
|
version = 0.1.148
|
||||||
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.2
|
Metadata-Version: 2.2
|
||||||
Name: guan
|
Name: guan
|
||||||
Version: 0.1.147
|
Version: 0.1.148
|
||||||
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
|
||||||
|
@ -24,7 +24,7 @@ def chat(prompt='你好', model=1, stream=1, stream_label=0):
|
|||||||
pass
|
pass
|
||||||
if stream == 1:
|
if stream == 1:
|
||||||
if stream_label == 1:
|
if stream_label == 1:
|
||||||
print('\n\n--- End Chat Stream Message ---\n')
|
print('\n--- End Chat Stream Message ---\n')
|
||||||
return response
|
return response
|
||||||
|
|
||||||
# 加上函数代码的 AI 对话
|
# 加上函数代码的 AI 对话
|
||||||
@ -61,68 +61,29 @@ def auto_chat_with_guide(prompt='你好', guide_message='(回答字数少于30
|
|||||||
|
|
||||||
# 在云端服务器上运行函数(需要函数是独立可运行的代码)
|
# 在云端服务器上运行函数(需要函数是独立可运行的代码)
|
||||||
def run(function_name, *args, **kwargs):
|
def run(function_name, *args, **kwargs):
|
||||||
import socket
|
import requests
|
||||||
import json
|
|
||||||
import pickle
|
|
||||||
import base64
|
|
||||||
import time
|
|
||||||
import guan
|
import guan
|
||||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client_socket:
|
url = "http://run.guanjihuan.com/run_function"
|
||||||
client_socket.connect(('run.guanjihuan.com', 12302))
|
function_source = guan.get_source(function_name)
|
||||||
function_source = guan.get_source(function_name)
|
data = {
|
||||||
split_text_list = guan.split_text(function_source, width=100)
|
"function_name": function_name.__name__,
|
||||||
message_times = len(split_text_list)
|
"function_source": function_source,
|
||||||
if message_times == 1 or message_times == 0:
|
'args': str(args),
|
||||||
message = {
|
'kwargs': str(kwargs),
|
||||||
'server': "run.guanjihuan.com",
|
}
|
||||||
'function_name': function_name.__name__,
|
return_data = None
|
||||||
'function_source': function_source,
|
try:
|
||||||
'args': str(args),
|
response = requests.post(url, json=data)
|
||||||
'kwargs': str(kwargs)
|
if response.status_code == 200:
|
||||||
}
|
result = response.json()
|
||||||
send_message = json.dumps(message)
|
print_data = result['print_data']
|
||||||
client_socket.send(send_message.encode())
|
print(print_data, end='')
|
||||||
else:
|
encoded_return_data = result['encoded_return_data']
|
||||||
end_message = 0
|
import base64
|
||||||
for i0 in range(message_times):
|
import pickle
|
||||||
if i0 == message_times-1:
|
return_data = pickle.loads(base64.b64decode(encoded_return_data))
|
||||||
end_message = 1
|
except:
|
||||||
source_0 = split_text_list[i0]
|
pass
|
||||||
message = {
|
|
||||||
'server': "run",
|
|
||||||
'function_name': function_name.__name__,
|
|
||||||
'function_source': source_0,
|
|
||||||
'args': str(args),
|
|
||||||
'kwargs': str(kwargs),
|
|
||||||
'end_message': end_message,
|
|
||||||
}
|
|
||||||
send_message = json.dumps(message)
|
|
||||||
client_socket.send(send_message.encode())
|
|
||||||
time.sleep(0.2)
|
|
||||||
print('\nguan.run: 云端服务器正在计算,请等待返回结果。\n')
|
|
||||||
return_data = ''
|
|
||||||
print_data = ''
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
data = client_socket.recv(1024)
|
|
||||||
return_text = data.decode()
|
|
||||||
return_dict = json.loads(return_text)
|
|
||||||
return_data += return_dict['return_data']
|
|
||||||
print_data += return_dict['print_data']
|
|
||||||
end_message = return_dict['end_message']
|
|
||||||
if end_message == 1:
|
|
||||||
break
|
|
||||||
except:
|
|
||||||
break
|
|
||||||
if print_data != '':
|
|
||||||
print('--- Start Print ---\n')
|
|
||||||
print(print_data)
|
|
||||||
print('--- End Print ---\n')
|
|
||||||
print('guan.run: 云端服务器计算结束,以上是打印结果。\n')
|
|
||||||
else:
|
|
||||||
print('guan.run: 云端服务器计算结束。\n')
|
|
||||||
return_data = pickle.loads(base64.b64decode(return_data))
|
|
||||||
# client_socket.close()
|
|
||||||
return return_data
|
return return_data
|
||||||
|
|
||||||
# 将XYZ数据转成矩阵数据(说明:x_array/y_array的输入和输出不一样。要求z_array数据中y对应的数据为小循环,x对应的数据为大循环)
|
# 将XYZ数据转成矩阵数据(说明:x_array/y_array的输入和输出不一样。要求z_array数据中y对应的数据为小循环,x对应的数据为大循环)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user