disable URL conversion during chunking and add debug logging for chunk content
This commit is contained in:
parent
8e78df00c0
commit
f476b6e476
1 changed files with 8 additions and 5 deletions
|
|
@ -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`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue