olivebot/llm/nlp_ChatGLM3.py
莣仔 059b6cee6d 年翻更新
1、修复服务器ip配置,配置页没替换问题;
2、修复开启状态偶尔没对齐问题;
3、修复关闭时关闭按钮停留在关闭中问题;
4、修复星座读取错误问题;
5、修复刷新重复提醒开启问题;
6、新增是否进行语音合成的选择;
7、文字沟通接口加入“观察描述”;
8、聊天记录时间改为毫秒级;
9、补充数字人和远程音频的连接状态显示;
10、修复备注填写无法保存问题。
2024-10-30 19:11:15 +08:00

36 lines
1.1 KiB
Python

import json
import requests
from core import content_db
def question(cont, uid=0, observation=""):
contentdb = content_db.new_instance()
if uid == 0:
list = contentdb.get_list('all','desc', 11)
else:
list = contentdb.get_list('all','desc', 11, uid)
answer_info = dict()
chat_list = []
i = len(list)-1
while i >= 0:
answer_info = dict()
if list[i][0] == "member":
answer_info["role"] = "user"
answer_info["content"] = list[i][2]
elif list[i][0] == "fay":
answer_info["role"] = "bot"
answer_info["content"] = list[i][2]
chat_list.append(answer_info)
i -= 1
content = {
"prompt":"请简单回复我。" + cont,
"history":chat_list}
url = "http://127.0.0.1:8000/v1/completions"
req = json.dumps(content)
headers = {'content-type': 'application/json'}
r = requests.post(url, headers=headers, data=req)
res = json.loads(r.text).get('response')
return req
if __name__ == "__main__":
question("你叫什么名字")