disable URL conversion during chunking and add debug logging for chunk content

This commit is contained in:
Russell Ballestrini 2025-07-11 20:43:09 -04:00
parent 8e78df00c0
commit f476b6e476

View file

@ -500,12 +500,10 @@ export async function translateHTML(htmlContent, targetLanguage, sourceUrl = nul
throw new Error("Unable to extract meaningful content from provided HTML.");
}
// Convert relative URLs to absolute if sourceUrl is provided
// Skip URL conversion during chunking to avoid performance overhead
// We'll add base tag instead which is more efficient
let processedContent = htmlContent;
if (sourceUrl) {
processedContent = convertRelativeToAbsolute(htmlContent, sourceUrl);
console.log('Converted relative URLs using base URL:', sourceUrl);
}
console.log('Skipping URL conversion for chunked translation - will use base tag instead');
// Use actual token limits instead of character limits
const maxTokens = getSelectedModelMaxTokens();
@ -528,6 +526,11 @@ export async function translateHTML(htmlContent, targetLanguage, sourceUrl = nul
const chunks = await splitHTMLIntoChunks(processedContent, availableTokens, getSelectedModel());
console.log(`Split into ${chunks.length} chunks for parallel translation`);
// Debug: log chunk content to see what we're actually translating
chunks.forEach((chunk, index) => {
console.log(`Chunk ${index + 1} preview:`, chunk.substring(0, 200) + (chunk.length > 200 ? '...' : ''));
});
// Translate all chunks in parallel using the normal translateText function
const translationPromises = chunks.map((chunk, index) => {
console.log(`Queued chunk ${index + 1}/${chunks.length} for translation`);