py3聊天机器人!

翻老项目的时候翻到的,没记错的话好像是跟着一个教程整的( ̄∇ ̄)

不知道还能用不

import json, requests
api_url = "http://openapi.tuling123.com/openapi/api/v2"

while  1:
    text_input = input('你:')
    data = {
        "perception":
        {
            "inputText":
            {
                "text": text_input
            },
        },
        "userInfo":
        {
            "apiKey": '211758c0166f45218de5a5a97b5e0c67',
            "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('图灵:' + results_text)
python
137 views
Comments
登录后评论
Sign In
·

聊起来还行,就是不大聪明 triumph

·

图灵测试失败 neutral_face

·

请求次数达到上限 怎么搞