Add types for global translation function

This commit is contained in:
Cohee
2025-02-19 22:18:09 +02:00
parent c12f26441e
commit 58bbfc0d4e
4 changed files with 13 additions and 5 deletions

View File

@ -561,9 +561,9 @@ async function retrieveFileChunks(queryText, collectionId) {
*/
async function vectorizeFile(fileText, fileName, collectionId, chunkSize, overlapPercent) {
try {
if (settings.translate_files && typeof window['translate'] === 'function') {
if (settings.translate_files && typeof globalThis.translate === 'function') {
console.log(`Vectors: Translating file ${fileName} to English...`);
const translatedText = await window['translate'](fileText, 'en');
const translatedText = await globalThis.translate(fileText, 'en');
fileText = translatedText;
}