feat(t2i): 为本地文本转图像功能添加文件服务支持

This commit is contained in:
Raven95676
2025-05-14 19:18:36 +08:00
parent d88683f498
commit 75c3d8abbd
2 changed files with 14 additions and 0 deletions
+6
View File
@@ -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",
@@ -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)]