You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
python-project/api/itca/bot.py

32 lines
1.2 KiB

import json
from tencentcloud.common import credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.tbp.v20190627 import tbp_client, models
def test(t):
try:
# 腾讯云的api接口
cred = credential.Credential("tencentcloud-api", "tencentcloud-secret")
httpProfile = HttpProfile()
httpProfile.endpoint = "tbp.tencentcloudapi.com"
clientProfile = ClientProfile()
clientProfile.httpProfile = httpProfile
client = tbp_client.TbpClient(cred, "", clientProfile)
req = models.TextProcessRequest()
params = {
"BotId": "5cbe9f65-8fdb-488f-8cd9-3d2905477525",
"BotEnv": "release",
"TerminalId": "123",
"InputText": t
}
req.from_json_string(json.dumps(params))
resp = client.TextProcess(req)
return eval(resp.to_json_string())["ResponseMessage"]['GroupList'][0]['Content']
except TencentCloudSDKException as err:
print('调试错误')