-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Images are not persistent on page refresh #705
Comments
I can raise a PRI can raise the PR for this, I have this running on my own for with this implementation: I just didn't because I didn't want to set up a new neon & blob db. export function convertToUIMessages(messages: Array<DBMessage>): Array<Message> {
return messages.reduce((chatMessages: Array<Message>, message) => {
if (message.role === 'tool') {
return addToolMessageToChat({
toolMessage: message as CoreToolMessage,
messages: chatMessages,
});
}
let textContent = '';
const toolInvocations: Array<ToolInvocation> = [];
const experimental_attachments: Attachment[] = [];
if (typeof message.content === 'string') {
textContent = message.content;
} else if (Array.isArray(message.content)) {
for (const content of message.content) {
if (content.type === 'text') {
textContent += content.text;
} else if (content.type === 'tool-call') {
toolInvocations.push({
state: 'call',
toolCallId: content.toolCallId,
toolName: content.toolName,
args: content.args,
});
} else if (content.type === 'image' && content.image) {
experimental_attachments.push({
name: content.name,
url: content.image,
contentType: 'image',
});
}
}
}
chatMessages.push({
id: message.id,
role: message.role as Message['role'],
content: textContent,
toolInvocations,
experimental_attachments: experimental_attachments.length > 0 ? experimental_attachments : undefined,
});
return chatMessages;
}, []);
} |
@conacts Do you actually get the correct name for the image after reloading the chat? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tracked this back to
convertToUIMessages
extracting and removing the images from our messages from database (const messagesFromDb = await getMessagesByChatId({ id });
).Is there anyway to retain these images, possibly using
convertToCoreMessages
rather thanconvertToUIMessages
? It seems we store our messages in our DB as Core Messages, what is the advantage to UI Messages over core messages?Screen.Recording.2025-01-13.at.10.57.19.AM.mov
The text was updated successfully, but these errors were encountered: