mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-09-24 15:36:23 +00:00
🔥 移除 hunyuan 相关文件
This commit is contained in:
@ -32,8 +32,8 @@ import nonebot_plugin_localstore as store # type: ignore
|
|||||||
from nonebot import get_driver, logger # type: ignore
|
from nonebot import get_driver, logger # type: ignore
|
||||||
|
|
||||||
from .config import config
|
from .config import config
|
||||||
from .dev import *
|
from .dev import * # noqa: F403
|
||||||
from .marsho import *
|
from .marsho import * # noqa: F403
|
||||||
from .metadata import metadata
|
from .metadata import metadata
|
||||||
|
|
||||||
# from .hunyuan import *
|
# from .hunyuan import *
|
||||||
|
@ -5,7 +5,6 @@ from nonebot import get_driver, logger, on_command, require
|
|||||||
from nonebot.adapters import Bot, Event
|
from nonebot.adapters import Bot, Event
|
||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot.typing import T_State
|
from nonebot.typing import T_State
|
||||||
from nonebot_plugin_argot import add_argot, get_message_id
|
|
||||||
|
|
||||||
from nonebot_plugin_marshoai.plugin.load import reload_plugin
|
from nonebot_plugin_marshoai.plugin.load import reload_plugin
|
||||||
|
|
||||||
@ -25,8 +24,8 @@ from nonebot_plugin_alconna import (
|
|||||||
on_alconna,
|
on_alconna,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .observer import *
|
from .observer import * # noqa: F403
|
||||||
from .plugin import get_plugin, get_plugins
|
from .plugin import get_plugin
|
||||||
from .plugin.func_call.caller import get_function_calls
|
from .plugin.func_call.caller import get_function_calls
|
||||||
|
|
||||||
driver = get_driver()
|
driver = get_driver()
|
||||||
|
@ -8,7 +8,7 @@ from nonebot import logger
|
|||||||
from .config import config
|
from .config import config
|
||||||
from .instances import context, driver, target_list, tools
|
from .instances import context, driver, target_list, tools
|
||||||
from .plugin import load_plugin, load_plugins
|
from .plugin import load_plugin, load_plugins
|
||||||
from .util import get_backup_context, save_context_to_json
|
from .util import save_context_to_json
|
||||||
|
|
||||||
|
|
||||||
@driver.on_startup
|
@driver.on_startup
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
import contextlib
|
|
||||||
import json
|
|
||||||
import traceback
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from arclet.alconna import Alconna, AllParam, Args
|
|
||||||
from nonebot import get_driver, logger, on_command
|
|
||||||
from nonebot.adapters import Event, Message
|
|
||||||
from nonebot.params import CommandArg
|
|
||||||
from nonebot.permission import SUPERUSER
|
|
||||||
from nonebot_plugin_alconna import MsgTarget, on_alconna
|
|
||||||
from nonebot_plugin_alconna.uniseg import UniMessage, UniMsg
|
|
||||||
|
|
||||||
from .config import config
|
|
||||||
from .constants import *
|
|
||||||
from .metadata import metadata
|
|
||||||
from .models import MarshoContext
|
|
||||||
from .util_hunyuan import *
|
|
||||||
|
|
||||||
genimage_cmd = on_alconna(
|
|
||||||
Alconna(
|
|
||||||
"genimage",
|
|
||||||
Args["prompt?", str],
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@genimage_cmd.handle()
|
|
||||||
async def genimage(event: Event, prompt=None):
|
|
||||||
if not prompt:
|
|
||||||
await genimage_cmd.finish("无提示词")
|
|
||||||
try:
|
|
||||||
result = generate_image(prompt)
|
|
||||||
url = json.loads(result)["ResultImage"]
|
|
||||||
await UniMessage.image(url=url).send()
|
|
||||||
except Exception as e:
|
|
||||||
# await genimage_cmd.finish(str(e))
|
|
||||||
traceback.print_exc()
|
|
@ -1,36 +0,0 @@
|
|||||||
import json
|
|
||||||
import types
|
|
||||||
|
|
||||||
from tencentcloud.common import credential # type: ignore
|
|
||||||
from tencentcloud.common.exception.tencent_cloud_sdk_exception import ( # type: ignore
|
|
||||||
TencentCloudSDKException,
|
|
||||||
)
|
|
||||||
from tencentcloud.common.profile.client_profile import ClientProfile # type: ignore
|
|
||||||
from tencentcloud.common.profile.http_profile import HttpProfile # type: ignore
|
|
||||||
from tencentcloud.hunyuan.v20230901 import hunyuan_client # type: ignore
|
|
||||||
from tencentcloud.hunyuan.v20230901 import models # type: ignore
|
|
||||||
|
|
||||||
from .config import config
|
|
||||||
|
|
||||||
|
|
||||||
def generate_image(prompt: str):
|
|
||||||
cred = credential.Credential(
|
|
||||||
config.marshoai_tencent_secretid, config.marshoai_tencent_secretkey
|
|
||||||
)
|
|
||||||
# 实例化一个http选项,可选的,没有特殊需求可以跳过
|
|
||||||
httpProfile = HttpProfile()
|
|
||||||
httpProfile.endpoint = "hunyuan.tencentcloudapi.com"
|
|
||||||
|
|
||||||
# 实例化一个client选项,可选的,没有特殊需求可以跳过
|
|
||||||
clientProfile = ClientProfile()
|
|
||||||
clientProfile.httpProfile = httpProfile
|
|
||||||
client = hunyuan_client.HunyuanClient(cred, "ap-guangzhou", clientProfile)
|
|
||||||
|
|
||||||
req = models.TextToImageLiteRequest()
|
|
||||||
params = {"Prompt": prompt, "RspImgType": "url", "Resolution": "1080:1920"}
|
|
||||||
req.from_json_string(json.dumps(params))
|
|
||||||
|
|
||||||
# 返回的resp是一个TextToImageLiteResponse的实例,与请求对象对应
|
|
||||||
resp = client.TextToImageLite(req)
|
|
||||||
# 输出json格式的字符串回包
|
|
||||||
return resp.to_json_string()
|
|
Reference in New Issue
Block a user