把回复消息中的 图片 全部插入消息体;

Black格式化代码
This commit is contained in:
2024-11-30 03:40:10 +08:00
parent 075a529aa1
commit a888442311
11 changed files with 277 additions and 93 deletions

View File

@ -3,11 +3,17 @@ import types
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.common.exception.tencent_cloud_sdk_exception import (
TencentCloudSDKException,
)
from tencentcloud.hunyuan.v20230901 import hunyuan_client, models
from .config import config
def generate_image(prompt: str):
cred = credential.Credential(config.marshoai_tencent_secretid, config.marshoai_tencent_secretkey)
cred = credential.Credential(
config.marshoai_tencent_secretid, config.marshoai_tencent_secretkey
)
# 实例化一个http选项可选的没有特殊需求可以跳过
httpProfile = HttpProfile()
httpProfile.endpoint = "hunyuan.tencentcloudapi.com"
@ -18,11 +24,7 @@ def generate_image(prompt: str):
client = hunyuan_client.HunyuanClient(cred, "ap-guangzhou", clientProfile)
req = models.TextToImageLiteRequest()
params = {
"Prompt": prompt,
"RspImgType": "url",
"Resolution": "1080:1920"
}
params = {"Prompt": prompt, "RspImgType": "url", "Resolution": "1080:1920"}
req.from_json_string(json.dumps(params))
# 返回的resp是一个TextToImageLiteResponse的实例与请求对象对应