import json, requests
api_url = 'http://openapi.tuling123.com/openapi/api/v2'
while 1:
text_input = input('我:')
data = {
'perception':
{
'inputText':
{
'text': text_input
},
# 可选参数
# 'inputImage': {
# 'url': 'imageUrl'
# },
# 可选参数
# 'selfInfo':
# {
# 'location':
# {
# 'city': '上海',
# 'province': '上海',
# 'street': '文汇路'
# }
# }
},
'userInfo':
{
'apiKey': '机器人的apiKey',
'userId': 'AA'
}
}
data = json.dumps(data).encode('utf8')
response_str = requests.post(api_url, data=data, headers={'content-type': 'application/json'})
response_dic = response_str.json()
results_text = response_dic['results'][0]['values']['text']
print('SB机器人:' + results_text)
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。