Add Nano Banana 2.1 and preserve image workflow values

This commit is contained in:
Jony
2026-10-07 13:33:40 +08:00
parent 10a8700589
commit 5212a59047
18 changed files with 480 additions and 295 deletions
+25 -8
View File
@@ -47,7 +47,7 @@ class PayloadTests(unittest.TestCase):
"智能",
)
for model in ("Nano Banana 2", "gpt-image-2", "Seedream 5.0 Pro"):
for model in ("Nano Banana 2.1", "Nano Banana 2", "gpt-image-2", "Seedream 5.0 Pro"):
with self.subTest(model=model):
job = JOBS.normalize_job_payload({
**_payload(),
@@ -293,12 +293,13 @@ class PayloadTests(unittest.TestCase):
"references": [{"name": "poster.png", "subfolder": "", "type": "input"}],
})
def test_google_search_is_kept_only_for_nano_banana_2_when_true(self):
enabled = JOBS.normalize_job_payload({**_payload(), "google_search": True})
self.assertIs(enabled["google_search"], True)
disabled = JOBS.normalize_job_payload({**_payload(), "google_search": False})
self.assertNotIn("google_search", disabled)
def test_google_search_is_kept_only_for_supported_nano_banana_models_when_true(self):
for model in ("Nano Banana 2.1", "Nano Banana 2"):
with self.subTest(model=model):
enabled = JOBS.normalize_job_payload({**_payload(), "model": model, "google_search": True})
self.assertIs(enabled["google_search"], True)
disabled = JOBS.normalize_job_payload({**_payload(), "model": model, "google_search": False})
self.assertNotIn("google_search", disabled)
unsupported = JOBS.normalize_job_payload({
**_payload(),
@@ -307,6 +308,18 @@ class PayloadTests(unittest.TestCase):
})
self.assertNotIn("google_search", unsupported)
def test_nano_banana_21_accepts_every_route_and_extended_aspect_ratio(self):
for route in ("畅速", "直连", "专线"):
for ratio in ("1:4", "1:8", "4:1", "8:1"):
with self.subTest(route=route, ratio=ratio):
job = JOBS.normalize_job_payload({
**_payload(), "model": "Nano Banana 2.1", "model_route": route,
"aspect_ratio": ratio, "google_search": True,
})
self.assertEqual(job["model"], "Nano Banana 2.1")
self.assertEqual(job["model_route"], route)
self.assertIs(job["google_search"], True)
def test_batch_prompts_expand_prompt_major_and_enforce_total_limit(self):
job = JOBS.normalize_job_payload({
**_payload(),
@@ -997,7 +1010,7 @@ class NanoExecutionTests(unittest.IsolatedAsyncioTestCase):
((0, 128, 0), (255, 255, 255)),
])
async def test_references_are_reused_as_exact_inline_data_without_urls(self):
async def test_nano_banana_21_reuses_inline_references_and_forwards_model_parameters(self):
calls = []
class FakeHttpClient:
@@ -1017,6 +1030,8 @@ class NanoExecutionTests(unittest.IsolatedAsyncioTestCase):
Image.new("RGB", (5, 4), "orange").save(reference_path, format="JPEG")
job = JOBS.normalize_job_payload({
**_payload(),
"model": "Nano Banana 2.1",
"model_route": "专线",
"prompt": "第一条\n---\n第二条",
"image_count": 2,
"google_search": True,
@@ -1049,6 +1064,8 @@ class NanoExecutionTests(unittest.IsolatedAsyncioTestCase):
self.assertEqual(len(calls), 4)
self.assertTrue(all(call["download_semaphore"] is None for call in calls))
self.assertTrue(all(call["google_search"] is True for call in calls))
self.assertTrue(all(call["model"] == "gemini-nano-banana-2.1" for call in calls))
self.assertTrue(all(call["thinking_level"] == "high" for call in calls))
self.assertEqual(
[call["prompt"] for call in calls],
["第一条", "第一条", "第二条", "第二条"],