Skip to content

Commit 819a44e

Browse files
Ark-kuncopybara-github
authored andcommitted
fix: GenAI - Fixed the Part.mime_type property
PiperOrigin-RevId: 628436837
1 parent 90efab2 commit 819a44e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

vertexai/generative_models/_generative_models.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1926,7 +1926,12 @@ def text(self) -> str:
19261926

19271927
@property
19281928
def mime_type(self) -> Optional[str]:
1929-
return self._raw_part.mime_type
1929+
part_type = self._raw_part._pb.WhichOneof("data")
1930+
if part_type == "inline_data":
1931+
return self._raw_part.inline_data.mime_type
1932+
if part_type == "file_data":
1933+
return self._raw_part.file_data.mime_type
1934+
raise AttributeError(f"Part has no mime_type.\nPart:\n{self.to_dict()}")
19301935

19311936
@property
19321937
def inline_data(self) -> gapic_content_types.Blob:

0 commit comments

Comments
 (0)