I've just implemented tidyverse/ellmer#1119 aimed at improving a bit of UX in ellmer; here's the 馃 summary of the equivalent in chatlas:
Once a file has been uploaded, reusing it in a later session means rebuilding the ContentUploaded yourself from what chat.files.get() returns:
from chatlas import ChatAnthropic, ContentUploaded
chat = ChatAnthropic()
meta = chat.files.get("file_011CRabc...")
report = ContentUploaded(id=meta.id, mime_type=meta.mime_type, provider=meta.provider)
chat.chat("Summarize the key findings.", report)
That works for Anthropic and Google, but fails for OpenAI because its file_get() sets mime_type=None and ContentUploaded.mime_type is a required str, so you have to guess the type from meta.filename yourself. ellmer is resolving this by having chat$file_get() return a ContentUploaded with the metadata on extra and guessing OpenAI's MIME type from the filename (tidyverse/ellmer#1116, tidyverse/ellmer#1119). Might be worth aligning, either by doing the same or by adding a FileMetadata.to_content() helper.
I've just implemented tidyverse/ellmer#1119 aimed at improving a bit of UX in ellmer; here's the 馃 summary of the equivalent in chatlas:
Once a file has been uploaded, reusing it in a later session means rebuilding the
ContentUploadedyourself from whatchat.files.get()returns:That works for Anthropic and Google, but fails for OpenAI because its
file_get()setsmime_type=NoneandContentUploaded.mime_typeis a requiredstr, so you have to guess the type frommeta.filenameyourself. ellmer is resolving this by havingchat$file_get()return aContentUploadedwith the metadata onextraand guessing OpenAI's MIME type from the filename (tidyverse/ellmer#1116, tidyverse/ellmer#1119). Might be worth aligning, either by doing the same or by adding aFileMetadata.to_content()helper.