12345678910111213141516171819202122232425 |
- from loguru import logger
- 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.nlp.v20190408 import nlp_client
- from app.core.config import settings
- def get_tencent_nlp_client() -> nlp_client.NlpClient:
- try:
- cred = credential.Credential(settings.TENCENT_SECRET_ID_V1, settings.TENCENT_SECRET_KEY_V1)
- http_profile = HttpProfile()
- http_profile.reqMethod = 'GET'
- http_profile.endpoint = settings.TENCENT_NLP_ENDPOINT
- client_profile = ClientProfile()
- client_profile.httpProfile = http_profile
- client = nlp_client.NlpClient(cred, 'ap-guangzhou', client_profile)
- return client
- except TencentCloudSDKException as e:
- logger.error(e)
|