compatible with openai bot

This commit is contained in:
lanvent
2023-03-13 19:58:35 +08:00
parent ad6ae0b32a
commit dce9c4dccb
3 changed files with 29 additions and 24 deletions

View File

@@ -2,6 +2,7 @@
import requests
from bot.bot import Bot
from bridge.reply import Reply, ReplyType
# Baidu Unit对话接口 (可用, 但能力较弱)
@@ -14,7 +15,8 @@ class BaiduUnitBot(Bot):
headers = {'content-type': 'application/x-www-form-urlencoded'}
response = requests.post(url, data=post_data.encode(), headers=headers)
if response:
return response.json()['result']['context']['SYS_PRESUMED_HIST'][1]
reply = Reply(ReplyType.TEXT, response.json()['result']['context']['SYS_PRESUMED_HIST'][1])
return reply
def get_token(self):
access_key = 'YOUR_ACCESS_KEY'