分享

Python实现简单的智能回答

 新用户79878317 2022-12-10 发布于河南
import json, requests api_url = 'http://openapi./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)

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多