Skip to content

No easy way to reuse an uploaded file from its id#417

Description

@thisisnic

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority: LowLow-impact bug, docs polish, papercut, or unclear low-severity request.ai-triage:doneMarks an issue whose AI triage workflow is complete.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions