Gemini inline video (#4078)

* Add inline video attachment support for Gemini 2.5 Pro

* file formatting

* removed redundant function for saving video to message

* removed other redundant function for saving video to message

* Seperate inlining check for video

* Edit video token cost to be a conservative estimate of 10000 tokens

* fixed missing semicolon

* Adds seperate ui toggle for video inlining.

* Move mes_video out of img_container

* Remove title from video element for now

* Better visibilty of video with controls

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
This commit is contained in:
Nikolas Brown
2025-06-01 08:04:16 -04:00
committed by GitHub
parent 3ec9b1a099
commit c4d89b2067
7 changed files with 159 additions and 3 deletions

View File

@@ -2473,6 +2473,31 @@ export function appendMediaToMessage(mes, messageElement, adjustScroll = true) {
}
}
// Add video to message
if (mes.extra?.video) {
const container = messageElement.find('.mes_block');
const chatHeight = $('#chat').prop('scrollHeight');
// Create video element if it doesn't exist
let video = messageElement.find('.mes_video');
if (video.length === 0) {
video = $('<video class="mes_video" controls preload="metadata"></video>');
container.append(video);
}
video.off('loadedmetadata').on('loadedmetadata', function () {
if (!adjustScroll) {
return;
}
const scrollPosition = $('#chat').scrollTop();
const newChatHeight = $('#chat').prop('scrollHeight');
const diff = newChatHeight - chatHeight;
$('#chat').scrollTop(scrollPosition + diff);
});
video.attr('src', mes.extra?.video);
}
// Add file to message
if (mes.extra?.file) {
messageElement.find('.mes_file_container').remove();