mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-22 13:34:17 +02:00
Added fix to always convert all items of a content list to content blocks
This commit is contained in:
parent
b549b4a323
commit
1b49523e01
1 changed files with 7 additions and 12 deletions
|
|
@ -544,15 +544,10 @@ def _convert_to_content(
|
|||
if all(isinstance(item, ContentBlock) for item in result):
|
||||
return result
|
||||
|
||||
# If any item is a ContentBlock, convert non-ContentBlock items to TextContent
|
||||
# without aggregating them
|
||||
if any(isinstance(item, ContentBlock) for item in result):
|
||||
return [
|
||||
_convert_to_single_content_block(item, serializer)
|
||||
if not isinstance(item, ContentBlock)
|
||||
else item
|
||||
for item in result
|
||||
]
|
||||
|
||||
# If none of the items are ContentBlocks, aggregate all items into a single TextContent
|
||||
return [TextContent(type="text", text=_serialize_with_fallback(result, serializer))]
|
||||
# Convert items that are not ContentBlocks
|
||||
return [
|
||||
_convert_to_single_content_block(item, serializer)
|
||||
if not isinstance(item, ContentBlock)
|
||||
else item
|
||||
for item in result
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue