Spaces:
Paused
fix(image): handle ChatGPT new async image-gen response format
Browse filesChatGPT moved the `async_task_type=image_gen` marker off the actual
image node (it now only sits on the "正在处理" placeholder card), and
finished images arrive as a separate tool/multimodal_text message whose
metadata has no async_task_type and whose asset_pointer is a
`sediment://` ref. The old strict gate
`metadata.async_task_type != "image_gen"` skipped the real image node,
so _poll_image_results always timed out -> "image task returned no
image data".
Drop the async_task_type gate; collect any tool multimodal_text message
that carries file-service:// or sediment:// pointers, and skip messages
with no image pointers. Handles both old and new formats, and now
returns both images of the A/B (paragen) pair.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@@ -619,10 +619,12 @@ class OpenAIBackendAPI:
|
|
| 619 |
content = message.get("content") or {}
|
| 620 |
if author.get("role") != "tool":
|
| 621 |
continue
|
| 622 |
-
if metadata.get("async_task_type") != "image_gen":
|
| 623 |
-
continue
|
| 624 |
if content.get("content_type") != "multimodal_text":
|
| 625 |
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
| 626 |
file_ids, sediment_ids = [], []
|
| 627 |
for part in content.get("parts") or []:
|
| 628 |
text = (part.get("asset_pointer") or "") if isinstance(part, dict) else (
|
|
@@ -633,6 +635,8 @@ class OpenAIBackendAPI:
|
|
| 633 |
for hit in sed_pat.findall(text):
|
| 634 |
if hit not in sediment_ids:
|
| 635 |
sediment_ids.append(hit)
|
|
|
|
|
|
|
| 636 |
records.append(
|
| 637 |
{"message_id": message_id, "create_time": message.get("create_time") or 0, "file_ids": file_ids,
|
| 638 |
"sediment_ids": sediment_ids})
|
|
|
|
| 619 |
content = message.get("content") or {}
|
| 620 |
if author.get("role") != "tool":
|
| 621 |
continue
|
|
|
|
|
|
|
| 622 |
if content.get("content_type") != "multimodal_text":
|
| 623 |
continue
|
| 624 |
+
# 新版异步生图: 图片节点不再带 metadata.async_task_type=image_gen,
|
| 625 |
+
# 该标记只留在"正在处理"占位卡上。这里改为只要是 tool 的 multimodal_text
|
| 626 |
+
# 且 parts 里含图片指针(file-service:// 或 sediment://)就采集。
|
| 627 |
+
_ = metadata # async_task_type 闸门已废弃,见上
|
| 628 |
file_ids, sediment_ids = [], []
|
| 629 |
for part in content.get("parts") or []:
|
| 630 |
text = (part.get("asset_pointer") or "") if isinstance(part, dict) else (
|
|
|
|
| 635 |
for hit in sed_pat.findall(text):
|
| 636 |
if hit not in sediment_ids:
|
| 637 |
sediment_ids.append(hit)
|
| 638 |
+
if not file_ids and not sediment_ids:
|
| 639 |
+
continue
|
| 640 |
records.append(
|
| 641 |
{"message_id": message_id, "create_time": message.get("create_time") or 0, "file_ids": file_ids,
|
| 642 |
"sediment_ids": sediment_ids})
|