diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index d9d604d6..8712ff72 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -92,6 +92,7 @@ DEFAULT_CONFIG = { "t2i_word_threshold": 150, "t2i_strategy": "remote", "t2i_endpoint": "", + "t2i_use_file_service": False, "http_proxy": "", "dashboard": { "enable": True, @@ -1448,6 +1449,11 @@ CONFIG_METADATA_2 = { "type": "string", "hint": "当 t2i_strategy 为 remote 时生效。为空时使用 AstrBot API 服务", }, + "t2i_use_file_service": { + "description": "本地文本转图像使用文件服务提供文件", + "type": "bool", + "hint": "当 t2i_strategy 为 local 并且配置 callback_api_base 时生效。是否使用文件服务提供文件。", + }, "pip_install_arg": { "description": "pip 安装参数", "type": "string", diff --git a/astrbot/core/pipeline/result_decorate/stage.py b/astrbot/core/pipeline/result_decorate/stage.py index 920e9204..fd1134ed 100644 --- a/astrbot/core/pipeline/result_decorate/stage.py +++ b/astrbot/core/pipeline/result_decorate/stage.py @@ -248,6 +248,14 @@ class ResultDecorateStage(Stage): if url: if url.startswith("http"): result.chain = [Image.fromURL(url)] + elif ( + self.ctx.astrbot_config["t2i_use_file_service"] + and self.ctx.astrbot_config["callback_api_base"] + ): + token = await file_token_service.register_file(url) + url = f"{self.ctx.astrbot_config['callback_api_base']}/api/file/{token}" + logger.debug(f"已注册:{url}") + result.chain = [Image.fromURL(url)] else: result.chain = [Image.fromFileSystem(url)]