mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-21 04:54:17 +02:00
Fixed so only converted fastmcp types
This commit is contained in:
parent
21bcfd52f7
commit
c82e1faa4e
1 changed files with 12 additions and 7 deletions
|
|
@ -544,10 +544,15 @@ def _convert_to_content(
|
|||
if all(isinstance(item, ContentBlock) for item in result):
|
||||
return result
|
||||
|
||||
# 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
|
||||
]
|
||||
# If any item is a ContentBlock, convert non-ContentBlock items to TextContent
|
||||
# without aggregating them
|
||||
if any(isinstance(item, (Image, Audio, File)) for item in result):
|
||||
return [
|
||||
_convert_to_single_content_block(item, serializer)
|
||||
if isinstance(item, (Image, Audio, File))
|
||||
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))]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue