Closed copybara-service[bot] closed 2 months ago
Enhancements to modalities.
lf.MimeType
lf.Mime
lf.Mime.from_url
lf.Mime.from_bytes
m = lf.Mime.from_uri('.../a.png') assert isinstance(m, lf.Image)
lf.Mime.is_text
lf.Mime.to_text
m = lf.Mime.from_bytes(b'hello world') assert m.is_text assert m.to_text() == 'hello world'
x = lf.modalities.Docx.from_uri(...) # Automatically converts to XML. y = m.make_compatible(['text/plain', 'image/png']) assert y.mime_type == 'text/plain'
Enhancements to modalities.
lf.MimeType
tolf.Mime
. (lf.MimeType
is kept as an alias)lf.Mime.from_url
andlf.Mime.from_bytes
to automatically detect subclasses to instantiate. e.g.:lf.Mime.is_text
andlf.Mime.to_text
for text detection and retrieval. e.g.::lf.MimeType
objects. Allow automatic modality conversion based on supported MIME types.