posit-dev / posit-dev/chatlas

No easy way to reuse an uploaded file from its id

Open
#417 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ai-triage:done Priority: Low
Dominant language
Python
Stars
176
Forks
28
Avg merge
18h 42m
Merged PRs (30d)
16

Description

I've just implemented https://github.com/tidyverse/ellmer/pull/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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing chat.files.get(), file_get(), FileMetadata, and ContentUploaded, then compare the equivalent ellmer changes in tidyverse/ellmer#1116 and #1119. Make a retrieved file reusable in a later chat, including suitable MIME metadata for OpenAI, or provide the proposed FileMetadata.to_content() helper; verify the existing Anthropic, Google, and OpenAI paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.