This commit is contained in:
guanjihuan 2025-02-22 11:32:09 +08:00
parent 65ae0be518
commit 78898443c3
3 changed files with 8 additions and 5 deletions

View File

@ -1,7 +1,7 @@
[metadata]
# replace with your username:
name = guan
version = 0.1.145
version = 0.1.147
author = guanjihuan
author_email = guanjihuan@163.com
description = An open source python package

View File

@ -1,6 +1,6 @@
Metadata-Version: 2.2
Name: guan
Version: 0.1.145
Version: 0.1.147
Summary: An open source python package
Home-page: https://py.guanjihuan.com
Author: guanjihuan

View File

@ -1,7 +1,7 @@
# Module: data_processing
# AI 对话
def chat(prompt='你好', model=1, stream=1):
def chat(prompt='你好', model=1, stream=1, stream_label=0):
import requests
url = "http://api.guanjihuan.com/chat"
data = {
@ -9,6 +9,7 @@ def chat(prompt='你好', model=1, stream=1):
"model": model,
}
if stream == 1:
if stream_label == 1:
print('\n--- Start Chat Stream Message ---\n')
requests_response = requests.post(url, json=data, stream=True)
response = ''
@ -18,9 +19,11 @@ def chat(prompt='你好', model=1, stream=1):
if stream == 1:
print(line.decode('utf-8'), end='', flush=True)
response += line.decode('utf-8')
print()
else:
pass
if stream == 1:
if stream_label == 1:
print('\n\n--- End Chat Stream Message ---\n')
return response