mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-29 08:44:48 +08:00
fix(middleware): return proper content format when no images viewed (#1454)
- Fix OpenAI BadRequestError: 'No images have been viewed.' was returned as
a plain string array instead of a properly formatted content block
- The OpenAI API expects message content to be either a string or an array
of objects with 'type' field, not an array of plain strings
- Changed return from ['No images have been viewed.'] to
[{'type': 'text', 'text': 'No images have been viewed.'}]
Fixes #1441
Co-authored-by: JasonOA888 <noreply@github.com>
This commit is contained in:
@@ -102,7 +102,8 @@ class ViewImageMiddleware(AgentMiddleware[ViewImageMiddlewareState]):
|
|||||||
"""
|
"""
|
||||||
viewed_images = state.get("viewed_images", {})
|
viewed_images = state.get("viewed_images", {})
|
||||||
if not viewed_images:
|
if not viewed_images:
|
||||||
return ["No images have been viewed."]
|
# Return a properly formatted text block, not a plain string array
|
||||||
|
return [{"type": "text", "text": "No images have been viewed."}]
|
||||||
|
|
||||||
# Build the message with image information
|
# Build the message with image information
|
||||||
content_blocks: list[str | dict] = [{"type": "text", "text": "Here are the images you've viewed:"}]
|
content_blocks: list[str | dict] = [{"type": "text", "text": "Here are the images you've viewed:"}]
|
||||||
|
|||||||
Reference in New Issue
Block a user