Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: image preview on chat messages #484

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

thiagobarbosa
Copy link

Fixes #475

Ideally I would keep the array of Attachment on the chat history so the attachments would be rendered by the PreviewAttachment component, but I noticed that doing that results in a overuse of tokens. Apparently the models keep processing those attachments for every follow up message, even when the follow up user messages only has texts (I only tested this with OpenAI's models but I believe this behaviour is not model-specific).

So this approach appends a markdown by the end of the text to render the images, and a new CSS class on globals.css makes it a little nicer.

Before:
Screenshot 2024-11-04 at 18 33 53

After:
Screenshot 2024-11-04 at 18 32 50

If the image is tall:
Screenshot 2024-11-04 at 18 38 32

Multiple images:
Screenshot 2024-11-04 at 18 47 19

Copy link

vercel bot commented Nov 4, 2024

@thiagobarbosa is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Preview for attached image is not showing on chat page
1 participant