fix: avoid cached reference image uploads
This commit is contained in:
+5
-1
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
import asyncio
|
||||
import sys
|
||||
import time
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
|
||||
import aiohttp
|
||||
@@ -54,6 +55,9 @@ class KieClient:
|
||||
return 5.0
|
||||
return 15.0
|
||||
|
||||
def build_reference_file_name(self, index: int) -> str:
|
||||
return f"reference_{index}_{uuid.uuid4().hex}.png"
|
||||
|
||||
async def _request_json(
|
||||
self,
|
||||
method: str,
|
||||
@@ -176,7 +180,7 @@ class KieClient:
|
||||
image_input.append(
|
||||
await self.upload_reference_image(
|
||||
reference_image_data_uri,
|
||||
file_name=f"reference_{index}.png",
|
||||
file_name=self.build_reference_file_name(index),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "wade-kieapi"
|
||||
description = "ComfyUI custom node for Kie Nano Banana 2 image generation with optional reference images."
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
license = { file = "LICENSE" }
|
||||
requires-python = ">=3.10"
|
||||
dynamic = ["dependencies"]
|
||||
|
||||
@@ -228,6 +228,7 @@ def test_generate_images_uploads_all_reference_images_in_order():
|
||||
client.create_nano_banana_2_task = fake_create_task
|
||||
client.wait_for_task = fake_wait_for_task
|
||||
client.download_result_images = fake_download_result_images
|
||||
client.build_reference_file_name = lambda index: f"unique-reference-{index}.png"
|
||||
|
||||
raw_images, task_id = asyncio.run(
|
||||
client.generate_images(
|
||||
@@ -248,12 +249,12 @@ def test_generate_images_uploads_all_reference_images_in_order():
|
||||
assert task_id == "task_multi_ref"
|
||||
assert raw_images == [b"image-bytes"]
|
||||
assert uploaded == [
|
||||
("data:image/png;base64,first", "reference_0.png"),
|
||||
("data:image/png;base64,second", "reference_1.png"),
|
||||
("data:image/png;base64,third", "reference_2.png"),
|
||||
("data:image/png;base64,first", "unique-reference-0.png"),
|
||||
("data:image/png;base64,second", "unique-reference-1.png"),
|
||||
("data:image/png;base64,third", "unique-reference-2.png"),
|
||||
]
|
||||
assert created_payload["image_input"] == [
|
||||
"https://example.com/reference_0.png",
|
||||
"https://example.com/reference_1.png",
|
||||
"https://example.com/reference_2.png",
|
||||
"https://example.com/unique-reference-0.png",
|
||||
"https://example.com/unique-reference-1.png",
|
||||
"https://example.com/unique-reference-2.png",
|
||||
]
|
||||
|
||||
@@ -22,7 +22,7 @@ def test_registry_metadata_and_workflow_files_exist():
|
||||
assert "[project]" in pyproject_text
|
||||
assert '[tool.comfy]' in pyproject_text
|
||||
assert 'name = "wade-kieapi"' in pyproject_text
|
||||
assert 'version = "0.1.3"' in pyproject_text
|
||||
assert 'version = "0.1.4"' in pyproject_text
|
||||
assert 'license = { file = "LICENSE" }' in pyproject_text
|
||||
assert 'dynamic = ["dependencies"]' in pyproject_text
|
||||
assert 'PublisherId = "wadesong"' in pyproject_text
|
||||
|
||||
Reference in New Issue
Block a user