@@ -284,10 +284,10 @@ function createAiSdkLocalizer(params: {
284284 ? `${ response . text . slice ( 0 , 500 ) } …`
285285 : response . text ;
286286 console . error (
287- `Failed to parse response from Lingo.dev . Response snippet: ${ snippet } ` ,
287+ `Failed to parse response from ${ params . id } . Response snippet: ${ snippet } ` ,
288288 ) ;
289289 throw new Error (
290- `Failed to parse response from Lingo.dev : ${ e2 } (Snippet: ${ snippet } )` ,
290+ `Failed to parse response from ${ params . id } : ${ e2 } (Snippet: ${ snippet } )` ,
291291 ) ;
292292 }
293293 let finalResult : Record < string , any > = { } ;
@@ -313,6 +313,13 @@ function createAiSdkLocalizer(params: {
313313 `Failed to parse nested JSON response: ${ e } (Snippet: ${ result . data . slice ( 0 , 100 ) } ...)` ,
314314 ) ;
315315 }
316+ } else {
317+ console . error (
318+ `Unexpected response format - no JSON object found. Snippet: ${ String ( result . data ) . slice ( 0 , 100 ) } ...` ,
319+ ) ;
320+ throw new Error (
321+ `Unexpected response format from ${ params . id } - no JSON object found in response` ,
322+ ) ;
316323 }
317324 }
318325
@@ -335,12 +342,12 @@ function createAiSdkLocalizer(params: {
335342 * @returns An array of payload chunks
336343 */
337344function extractPayloadChunks (
338- payload : Record < string , string > ,
345+ payload : Record < string , any > ,
339346 batchSize ?: number ,
340- ) : Record < string , string > [ ] {
347+ ) : Record < string , any > [ ] {
341348 const idealBatchItemSize = 250 ;
342- const result : Record < string , string > [ ] = [ ] ;
343- let currentChunk : Record < string , string > = { } ;
349+ const result : Record < string , any > [ ] = [ ] ;
350+ let currentChunk : Record < string , any > = { } ;
344351 let currentChunkItemCount = 0 ;
345352
346353 const payloadEntries = Object . entries ( payload ) ;
0 commit comments