From 85f9228220e558579248aa5ca72005655d0baedd Mon Sep 17 00:00:00 2001 From: o1key <951565127@qq.com> Date: Mon, 27 Apr 2026 12:25:58 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=20NanoBananaPro=20=E5=8D=95?= =?UTF-8?q?=E5=BC=A0=E6=A8=A1=E5=BC=8F=E7=9A=84=E8=87=AA=E5=8A=A8=E9=87=8D?= =?UTF-8?q?=E8=AF=95=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nodes/nano_banana_pro.py | 47 +++++++++++++--------------------------- 1 file changed, 15 insertions(+), 32 deletions(-) diff --git a/nodes/nano_banana_pro.py b/nodes/nano_banana_pro.py index 9daad2b..cdb4a98 100644 --- a/nodes/nano_banana_pro.py +++ b/nodes/nano_banana_pro.py @@ -686,38 +686,21 @@ class NanoBananaPro: else: # 单提示词模式 if 生图数量 == 1: - # 单张:同步生成,自动重试(429/503/504) - _RETRY_CODES = ("429", "503", "504") - _MAX_RETRIES = 5 - for _attempt in range(1, _MAX_RETRIES + 1): - try: - generated_images = self.client.generate_sync( - prompt=prompt, - model=模型, - resolution=分辨率, - aspect_ratio=宽高比, - batch_size=1, - images=input_images, - progress_callback=progress_callback, - debug=DEBUG_LOG_ENABLED, - debug_request=REQUEST_LOG_ENABLED, - enable_grounding=enable_grounding, - enable_image_search=enable_image_search, - image_format=image_format, - ) - break - except RuntimeError as e: - error_msg = str(e) - if any(code in error_msg for code in _RETRY_CODES) and _attempt < _MAX_RETRIES: - _wait = 2 ** _attempt - print(f"{'=' * 60}") - print(f"⚠️ Nano Banana Pro 自动重试 [{_attempt}/{_MAX_RETRIES - 1}]") - print(f" 原因:{error_msg}") - print(f" 等待 {_wait}s 后重试...") - print(f"{'=' * 60}") - time.sleep(_wait) - else: - raise + # 单张:同步生成 + generated_images = self.client.generate_sync( + prompt=prompt, + model=模型, + resolution=分辨率, + aspect_ratio=宽高比, + batch_size=1, + images=input_images, + progress_callback=progress_callback, + debug=DEBUG_LOG_ENABLED, + debug_request=REQUEST_LOG_ENABLED, + enable_grounding=enable_grounding, + enable_image_search=enable_image_search, + image_format=image_format, + ) else: # 多张:异步并发,内存输出