a42a72081d
1、web socket接口增加数字人文字内容同步,以便数人字可以远程运行; 2、优化数字人数据web socket同步逻辑; 3、更改gpt 3.5对接方式.
16 lines
535 B
Python
16 lines
535 B
Python
import json
|
|
import requests
|
|
|
|
from utils import config_util as cfg
|
|
|
|
def question(cont):
|
|
url="https://api.openai.com/v1/chat/completions"
|
|
req = json.dumps({
|
|
"model": "gpt-3.5-turbo",
|
|
"messages": [{"role": "user", "content": cont}],
|
|
"temperature": 0.7})
|
|
headers = {'content-type': 'application/json', 'Authorization': 'Bearer ' + cfg.key_chatgpt_api_key}
|
|
r = requests.post(url, headers=headers, data=req)
|
|
rsp = json.loads(r.text).get('choices')
|
|
a = rsp[0]['message']['content']
|
|
return a |