From 7eb22743d89f5a9c377b80ad349e1f050c9a5303 Mon Sep 17 00:00:00 2001 From: Asankilp Date: Fri, 5 Sep 2025 15:34:49 +0800 Subject: [PATCH] =?UTF-8?q?:fire:=20=E7=A7=BB=E9=99=A4=20hunyuan=20?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_marshoai/__init__.py | 4 +-- nonebot_plugin_marshoai/dev.py | 5 ++-- nonebot_plugin_marshoai/hooks.py | 2 +- nonebot_plugin_marshoai/hunyuan.py | 38 ------------------------- nonebot_plugin_marshoai/util_hunyuan.py | 36 ----------------------- 5 files changed, 5 insertions(+), 80 deletions(-) delete mode 100755 nonebot_plugin_marshoai/hunyuan.py delete mode 100755 nonebot_plugin_marshoai/util_hunyuan.py diff --git a/nonebot_plugin_marshoai/__init__.py b/nonebot_plugin_marshoai/__init__.py index 228a0cf..ccd9e02 100755 --- a/nonebot_plugin_marshoai/__init__.py +++ b/nonebot_plugin_marshoai/__init__.py @@ -32,8 +32,8 @@ import nonebot_plugin_localstore as store # type: ignore from nonebot import get_driver, logger # type: ignore from .config import config -from .dev import * -from .marsho import * +from .dev import * # noqa: F403 +from .marsho import * # noqa: F403 from .metadata import metadata # from .hunyuan import * diff --git a/nonebot_plugin_marshoai/dev.py b/nonebot_plugin_marshoai/dev.py index 9c80beb..14f66f1 100644 --- a/nonebot_plugin_marshoai/dev.py +++ b/nonebot_plugin_marshoai/dev.py @@ -5,7 +5,6 @@ from nonebot import get_driver, logger, on_command, require from nonebot.adapters import Bot, Event from nonebot.matcher import Matcher 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 @@ -25,8 +24,8 @@ from nonebot_plugin_alconna import ( on_alconna, ) -from .observer import * -from .plugin import get_plugin, get_plugins +from .observer import * # noqa: F403 +from .plugin import get_plugin from .plugin.func_call.caller import get_function_calls driver = get_driver() diff --git a/nonebot_plugin_marshoai/hooks.py b/nonebot_plugin_marshoai/hooks.py index 6e6f439..5f6c4f7 100644 --- a/nonebot_plugin_marshoai/hooks.py +++ b/nonebot_plugin_marshoai/hooks.py @@ -8,7 +8,7 @@ from nonebot import logger from .config import config from .instances import context, driver, target_list, tools 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 diff --git a/nonebot_plugin_marshoai/hunyuan.py b/nonebot_plugin_marshoai/hunyuan.py deleted file mode 100755 index 9e52189..0000000 --- a/nonebot_plugin_marshoai/hunyuan.py +++ /dev/null @@ -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() diff --git a/nonebot_plugin_marshoai/util_hunyuan.py b/nonebot_plugin_marshoai/util_hunyuan.py deleted file mode 100755 index 8bc68bb..0000000 --- a/nonebot_plugin_marshoai/util_hunyuan.py +++ /dev/null @@ -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()