点此进入CSDN

点此添加QQ好友 加载失败时会显示




百度技能问答模型

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())

  

posted @ 2020-08-25 16:06  高颜值的殺生丸  阅读(148)  评论(0编辑  收藏  举报

作者信息

昵称:

刘新宇

园龄:4年6个月


粉丝:1209


QQ:522414928