forked from xszyou/Fay
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1、web socket接口增加数字人文字内容同步,以便数人字可以远程运行; 2、优化数字人数据web socket同步逻辑; 3、更改gpt 3.5对接方式.
- Loading branch information
Showing
4 changed files
with
27 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
import json | ||
import requests | ||
|
||
from utils import config_util as cfg | ||
import openai | ||
|
||
def question(text): | ||
cfg.load_config() | ||
openai.api_key = cfg.key_chatgpt_api_key | ||
prompt = text | ||
completions = openai.Completion.create(engine="text-davinci-002", prompt=prompt, max_tokens=1024) | ||
a_msg = completions.choices[0].text | ||
return a_msg | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.