1616FILE = 'file'
1717IMAGE = 'image'
1818AUDIO = 'audio'
19+ VIDEO = 'video'
1920
2021
2122class BaseModelCompatibleDict (BaseModel ):
@@ -66,13 +67,15 @@ class ContentItem(BaseModelCompatibleDict):
6667 image : Optional [str ] = None
6768 file : Optional [str ] = None
6869 audio : Optional [str ] = None
70+ video : Optional [Union [str , list ]] = None
6971
7072 def __init__ (self ,
7173 text : Optional [str ] = None ,
7274 image : Optional [str ] = None ,
7375 file : Optional [str ] = None ,
74- audio : Optional [str ] = None ):
75- super ().__init__ (text = text , image = image , file = file , audio = audio )
76+ audio : Optional [str ] = None ,
77+ video : Optional [Union [str , list ]] = None ):
78+ super ().__init__ (text = text , image = image , file = file , audio = audio , video = video )
7679
7780 @model_validator (mode = 'after' )
7881 def check_exclusivity (self ):
@@ -85,21 +88,23 @@ def check_exclusivity(self):
8588 provided_fields += 1
8689 if self .audio :
8790 provided_fields += 1
91+ if self .video :
92+ provided_fields += 1
8893
8994 if provided_fields != 1 :
90- raise ValueError ("Exactly one of 'text', 'image', 'file', or 'audio ' must be provided." )
95+ raise ValueError ("Exactly one of 'text', 'image', 'file', 'audio', or 'video ' must be provided." )
9196 return self
9297
9398 def __repr__ (self ):
9499 return f'ContentItem({ self .model_dump ()} )'
95100
96- def get_type_and_value (self ) -> Tuple [Literal ['text' , 'image' , 'file' , 'audio' ], str ]:
101+ def get_type_and_value (self ) -> Tuple [Literal ['text' , 'image' , 'file' , 'audio' , 'video' ], str ]:
97102 (t , v ), = self .model_dump ().items ()
98- assert t in ('text' , 'image' , 'file' , 'audio' )
103+ assert t in ('text' , 'image' , 'file' , 'audio' , 'video' )
99104 return t , v
100105
101106 @property
102- def type (self ) -> Literal ['text' , 'image' , 'file' , 'audio' ]:
107+ def type (self ) -> Literal ['text' , 'image' , 'file' , 'audio' , 'video' ]:
103108 t , v = self .get_type_and_value ()
104109 return t
105110
0 commit comments