import { v4 as uuidv4 } from 'uuid'; import sha256 from 'js-sha256'; import { WEBUI_BASE_URL } from '$lib/constants'; import { TTS_RESPONSE_SPLIT } from '$lib/types'; ////////////////////////// // Helper functions ////////////////////////// export const replaceTokens = (content, char, user) => { const charToken = /{{char}}/gi; const userToken = /{{user}}/gi; const videoIdToken = /{{VIDEO_FILE_ID_([a-f0-9-]+)}}/gi; // Regex to capture the video ID const htmlIdToken = /{{HTML_FILE_ID_([a-f0-9-]+)}}/gi; // Regex to capture the HTML ID // Replace {{char}} if char is provided if (char !== undefined && char !== null) { content = content.replace(charToken, char); } // Replace {{user}} if user is provided if (user !== undefined && user !== null) { content = content.replace(userToken, user); } // Replace video ID tags with corresponding