首页 > 其他 > 详细

百度技能问答模型

时间:2020-08-25 16:39:32      阅读:69      评论:0      收藏:0      [点我收藏+]
import requests

# client_id 为官网获取的AK, client_secret 为官网获取的SK
host = ‘https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=hIkC0fSxfQX17dGsbVcUGYzx&client_secret=wluN6dVLGjUlnyvxtiSzQzchrHnv4O2K‘
response = requests.get(host)
if response:
    text_dict = response.json()
    access_token = text_dict[‘access_token‘]
    print(access_token)

url = ‘https://aip.baidubce.com/rpc/2.0/unit/bot/chat?access_token=‘ + access_token
post_data = "{\"bot_session\":\"\",\"log_id\":\"7758521\",\"request\":{\"bernard_level\":1,\"client_session\":\"{\\\"client_results\\\":\\\"\\\", \\\"candidate_options\\\":[]}\",\"query\":\"格力空调价格怎么样?\",\"query_info\":{\"asr_candidates\":[],\"source\":\"KEYBOARD\",\"type\":\"TEXT\"},\"updates\":\"\",\"user_id\":\"88888\"},\"bot_id\":\"1042747\",\"version\":\"2.0\"}".encode("utf-8")
headers = {‘content-type‘: ‘application/x-www-form-urlencoded‘}
response = requests.post(url, data=post_data, headers=headers)
if response:
    print (response.json())

  

百度技能问答模型

原文:https://www.cnblogs.com/LiuXinyu12378/p/13560232.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!