Skip to content

use-chat-attachments-url: Uploaded files are not recognized correctly by the model #2563

Answered by lesenelir
lesenelir asked this question in Help
Discussion options

You must be logged in to vote

convertToCoreMessages

attachmentsToParts

When calling convertToCoreMessages, attachments are converted to base64. So if a URL is from the database, it also needs to be converted to base64 in /api/chat/route.ts.

A possible solution:

// It might cause the pending time to be longer.
// PERFORMANCE: JUST PROCESS THE LAST MESSAGE ATTACHMENTS, Trade-off between performance and message completeness.
const processedMessagesPromises = messages.map(
  async (message: ResponseMessage) => {
    if (message.experimental_attachments) {
      const processedAttachments = await Promise.all(
        message.experimental_attachments.map(async (attachment) => {
          switch (attachment.contentType) {

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by lesenelir
Comment options

You must be logged in to vote
2 replies
@lesenelir
Comment options

@xsayedmahmud
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants