mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
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:
@@ -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();
|
||||
|
Reference in New Issue
Block a user