1
1
from __future__ import annotations as _annotations
2
2
3
- import hashlib
4
3
import uuid
5
4
from collections .abc import Sequence
6
5
from dataclasses import dataclass , field , replace
45
44
VideoFormat : TypeAlias = Literal ['mkv' , 'mov' , 'mp4' , 'webm' , 'flv' , 'mpeg' , 'mpg' , 'wmv' , 'three_gp' ]
46
45
47
46
48
- def _multi_modal_content_identifier (identifier : str | bytes ) -> str :
49
- if isinstance (identifier , str ):
50
- identifier = identifier .encode ('utf-8' )
51
- return hashlib .sha1 (identifier ).hexdigest ()[:6 ]
52
-
53
-
54
47
@dataclass
55
48
class SystemPromptPart :
56
49
"""A system prompt, generally written by the application developer.
@@ -87,10 +80,6 @@ class VideoUrl:
87
80
kind : Literal ['video-url' ] = 'video-url'
88
81
"""Type identifier, this is available on all parts as a discriminator."""
89
82
90
- @property
91
- def identifier (self ) -> str :
92
- return _multi_modal_content_identifier (self .url )
93
-
94
83
@property
95
84
def media_type (self ) -> VideoMediaType : # pragma: no cover
96
85
"""Return the media type of the video, based on the url."""
@@ -132,10 +121,6 @@ class AudioUrl:
132
121
kind : Literal ['audio-url' ] = 'audio-url'
133
122
"""Type identifier, this is available on all parts as a discriminator."""
134
123
135
- @property
136
- def identifier (self ) -> str :
137
- return _multi_modal_content_identifier (self .url )
138
-
139
124
@property
140
125
def media_type (self ) -> AudioMediaType :
141
126
"""Return the media type of the audio file, based on the url."""
@@ -157,10 +142,6 @@ class ImageUrl:
157
142
kind : Literal ['image-url' ] = 'image-url'
158
143
"""Type identifier, this is available on all parts as a discriminator."""
159
144
160
- @property
161
- def identifier (self ) -> str :
162
- return _multi_modal_content_identifier (self .url )
163
-
164
145
@property
165
146
def media_type (self ) -> ImageMediaType :
166
147
"""Return the media type of the image, based on the url."""
@@ -194,10 +175,6 @@ class DocumentUrl:
194
175
kind : Literal ['document-url' ] = 'document-url'
195
176
"""Type identifier, this is available on all parts as a discriminator."""
196
177
197
- @property
198
- def identifier (self ) -> str :
199
- return _multi_modal_content_identifier (self .url )
200
-
201
178
@property
202
179
def media_type (self ) -> str :
203
180
"""Return the media type of the document, based on the url."""
@@ -228,10 +205,6 @@ class BinaryContent:
228
205
kind : Literal ['binary' ] = 'binary'
229
206
"""Type identifier, this is available on all parts as a discriminator."""
230
207
231
- @property
232
- def identifier (self ) -> str :
233
- return _multi_modal_content_identifier (self .data )
234
-
235
208
@property
236
209
def is_audio (self ) -> bool :
237
210
"""Return `True` if the media type is an audio type."""
0 commit comments