File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
pydantic_ai_slim/pydantic_ai Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -1070,7 +1070,7 @@ class FilePart:
10701070
10711071 def has_content (self ) -> bool :
10721072 """Return `True` if the file content is non-empty."""
1073- return bool (self .content ) # pragma: no cover
1073+ return bool (self .content . data )
10741074
10751075 __repr__ = _utils .dataclasses_no_defaults_repr
10761076
Original file line number Diff line number Diff line change @@ -422,6 +422,14 @@ def test_pre_usage_refactor_messages_deserializable():
422422 )
423423
424424
425+ def test_file_part_has_content ():
426+ filepart = FilePart (content = BinaryContent (data = b'' , media_type = 'application/pdf' ))
427+ assert not filepart .has_content ()
428+
429+ filepart .content .data = b'not empty'
430+ assert filepart .has_content ()
431+
432+
425433def test_file_part_serialization_roundtrip ():
426434 # Verify that a serialized BinaryImage doesn't come back as a BinaryContent.
427435 messages : list [ModelMessage ] = [
You can’t perform that action at this time.
0 commit comments