0.1.30
This commit is contained in:
parent
7190c99b8e
commit
6c2c155159
@ -1,7 +1,7 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
# replace with your username:
|
# replace with your username:
|
||||||
name = guan
|
name = guan
|
||||||
version = 0.1.29
|
version = 0.1.30
|
||||||
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.29
|
Version: 0.1.30
|
||||||
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
|
||||||
|
@ -385,14 +385,21 @@ def get_PID(name):
|
|||||||
return id_running
|
return id_running
|
||||||
|
|
||||||
# 在服务器上运行大语言模型,通过Python函数调用
|
# 在服务器上运行大语言模型,通过Python函数调用
|
||||||
def chat(prompt='你好', stream_show=1):
|
def chat(prompt='你好', stream_show=1, top_p=0.8, temperature=0.8):
|
||||||
import socket
|
import socket
|
||||||
|
import json
|
||||||
response = ''
|
response = ''
|
||||||
try:
|
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(10)
|
client_socket.settimeout(10)
|
||||||
client_socket.connect(('socket.guanjihuan.com', 12345))
|
client_socket.connect(('socket.guanjihuan.com', 12345))
|
||||||
send_message = "chat.guanjihuan.com |---| " + prompt
|
message = {
|
||||||
|
'server': "chat.guanjihuan.com",
|
||||||
|
'prompt': prompt,
|
||||||
|
'top_p': top_p,
|
||||||
|
'temperature': temperature,
|
||||||
|
}
|
||||||
|
send_message = json.dumps(message)
|
||||||
client_socket.send(send_message.encode())
|
client_socket.send(send_message.encode())
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
@ -402,7 +409,6 @@ def chat(prompt='你好', stream_show=1):
|
|||||||
break
|
break
|
||||||
stream_response = data.decode()
|
stream_response = data.decode()
|
||||||
if '连接失败!请过段时间再试或者联系管理员。' in stream_response:
|
if '连接失败!请过段时间再试或者联系管理员。' in stream_response:
|
||||||
response = None
|
|
||||||
print('连接失败!请过段时间再试或者联系管理员。')
|
print('连接失败!请过段时间再试或者联系管理员。')
|
||||||
break
|
break
|
||||||
if stream_response == '':
|
if stream_response == '':
|
||||||
@ -416,7 +422,6 @@ def chat(prompt='你好', stream_show=1):
|
|||||||
pass
|
pass
|
||||||
client_socket.close()
|
client_socket.close()
|
||||||
except:
|
except:
|
||||||
response = None
|
|
||||||
print('连接失败!请过段时间再试或者联系管理员。')
|
print('连接失败!请过段时间再试或者联系管理员。')
|
||||||
import guan
|
import guan
|
||||||
guan.statistics_of_guan_package()
|
guan.statistics_of_guan_package()
|
||||||
|
@ -30,12 +30,13 @@ def get_calling_function_name(layer=1):
|
|||||||
global_variable_of_first_guan_package_calling = []
|
global_variable_of_first_guan_package_calling = []
|
||||||
def statistics_of_guan_package():
|
def statistics_of_guan_package():
|
||||||
import guan
|
import guan
|
||||||
message = guan.get_calling_function_name(layer=2)
|
import json
|
||||||
message_calling = guan.get_calling_function_name(layer=3)
|
function_name = guan.get_calling_function_name(layer=2)
|
||||||
|
function_calling_name = guan.get_calling_function_name(layer=3)
|
||||||
global global_variable_of_first_guan_package_calling
|
global global_variable_of_first_guan_package_calling
|
||||||
if message not in global_variable_of_first_guan_package_calling:
|
if function_name not in global_variable_of_first_guan_package_calling:
|
||||||
global_variable_of_first_guan_package_calling.append(message)
|
global_variable_of_first_guan_package_calling.append(function_name)
|
||||||
if message_calling == '<module>':
|
if function_calling_name == '<module>':
|
||||||
try:
|
try:
|
||||||
import socket
|
import socket
|
||||||
datetime_date = guan.get_date()
|
datetime_date = guan.get_date()
|
||||||
@ -45,7 +46,14 @@ def statistics_of_guan_package():
|
|||||||
client_socket.settimeout(0.5)
|
client_socket.settimeout(0.5)
|
||||||
client_socket.connect(('socket.guanjihuan.com', 12345))
|
client_socket.connect(('socket.guanjihuan.com', 12345))
|
||||||
mac_address = guan.get_mac_address()
|
mac_address = guan.get_mac_address()
|
||||||
send_message = datetime_date + ' ' + datetime_time + ' version_'+current_version + ' MAC_address: '+mac_address+' guan.' + message+'\n'
|
message = {
|
||||||
|
'date': datetime_date,
|
||||||
|
'time': datetime_time,
|
||||||
|
'version': current_version,
|
||||||
|
'MAC_address': mac_address,
|
||||||
|
'function_name': function_name
|
||||||
|
}
|
||||||
|
send_message = json.dumps(message)
|
||||||
client_socket.send(send_message.encode())
|
client_socket.send(send_message.encode())
|
||||||
client_socket.close()
|
client_socket.close()
|
||||||
except:
|
except:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user