0.1.147
This commit is contained in:
parent
65ae0be518
commit
78898443c3
@ -1,7 +1,7 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
# replace with your username:
|
# replace with your username:
|
||||||
name = guan
|
name = guan
|
||||||
version = 0.1.145
|
version = 0.1.147
|
||||||
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.145
|
Version: 0.1.147
|
||||||
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
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Module: data_processing
|
# Module: data_processing
|
||||||
|
|
||||||
# AI 对话
|
# AI 对话
|
||||||
def chat(prompt='你好', model=1, stream=1):
|
def chat(prompt='你好', model=1, stream=1, stream_label=0):
|
||||||
import requests
|
import requests
|
||||||
url = "http://api.guanjihuan.com/chat"
|
url = "http://api.guanjihuan.com/chat"
|
||||||
data = {
|
data = {
|
||||||
@ -9,7 +9,8 @@ def chat(prompt='你好', model=1, stream=1):
|
|||||||
"model": model,
|
"model": model,
|
||||||
}
|
}
|
||||||
if stream == 1:
|
if stream == 1:
|
||||||
print('\n--- Start Chat Stream Message ---\n')
|
if stream_label == 1:
|
||||||
|
print('\n--- Start Chat Stream Message ---\n')
|
||||||
requests_response = requests.post(url, json=data, stream=True)
|
requests_response = requests.post(url, json=data, stream=True)
|
||||||
response = ''
|
response = ''
|
||||||
if requests_response.status_code == 200:
|
if requests_response.status_code == 200:
|
||||||
@ -18,10 +19,12 @@ def chat(prompt='你好', model=1, stream=1):
|
|||||||
if stream == 1:
|
if stream == 1:
|
||||||
print(line.decode('utf-8'), end='', flush=True)
|
print(line.decode('utf-8'), end='', flush=True)
|
||||||
response += line.decode('utf-8')
|
response += line.decode('utf-8')
|
||||||
|
print()
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
if stream == 1:
|
if stream == 1:
|
||||||
print('\n\n--- End Chat Stream Message ---\n')
|
if stream_label == 1:
|
||||||
|
print('\n\n--- End Chat Stream Message ---\n')
|
||||||
return response
|
return response
|
||||||
|
|
||||||
# 加上函数代码的 AI 对话
|
# 加上函数代码的 AI 对话
|
||||||
|
Loading…
x
Reference in New Issue
Block a user