Skip to content

Commit ac24dd4

Browse files
committed
Fix js streaming examples.
1 parent 119cdaf commit ac24dd4

5 files changed

Lines changed: 27 additions & 18 deletions

File tree

docs/model-api/docs/task/audio-text-to-text.mdx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,9 @@ mode: 'wide'
243243
let text = '';
244244

245245
for await (const chunk of readStream) {
246-
text += chunk;
247-
console.log(chunk);
246+
const chunkText = chunk.toString();
247+
console.log(chunkText);
248+
text += chunkText;
248249
}
249250

250251
// observe the output
@@ -362,8 +363,9 @@ mode: 'wide'
362363
let text = '';
363364

364365
for await (const chunk of readStream) {
365-
text += chunk;
366-
console.log(chunk);
366+
const chunkText = chunk.toString();
367+
console.log(chunkText);
368+
text += chunkText;
367369
}
368370

369371
// observe the output

docs/model-api/docs/task/chat.mdx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,9 @@ mode: 'wide'
236236
let text = '';
237237

238238
for await (const chunk of readStream) {
239-
text += chunk;
240-
console.log(chunk);
239+
const chunkText = chunk.toString();
240+
console.log(chunkText);
241+
text += chunkText;
241242
}
242243

243244
// observe the output
@@ -352,8 +353,9 @@ mode: 'wide'
352353
let text = '';
353354
354355
for await (const chunk of readStream) {
355-
text += chunk;
356-
console.log(chunk);
356+
const chunkText = chunk.toString();
357+
console.log(chunkText);
358+
text += chunkText;
357359
}
358360
359361
// observe the output

docs/model-api/docs/task/image-text-to-text.mdx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,9 @@ mode: 'wide'
243243
let text = '';
244244

245245
for await (const chunk of readStream) {
246-
text += chunk;
247-
console.log(chunk);
246+
const chunkText = chunk.toString();
247+
console.log(chunkText);
248+
text += chunkText;
248249
}
249250

250251
// observe the output
@@ -362,8 +363,9 @@ mode: 'wide'
362363
let text = '';
363364

364365
for await (const chunk of readStream) {
365-
text += chunk;
366-
console.log(chunk);
366+
const chunkText = chunk.toString();
367+
console.log(chunkText);
368+
text += chunkText;
367369
}
368370

369371
// observe the output

docs/model-api/docs/task/video-text-to-text.mdx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,9 @@ mode: 'wide'
243243
let text = '';
244244

245245
for await (const chunk of readStream) {
246-
text += chunk;
247-
console.log(chunk);
246+
const chunkText = chunk.toString();
247+
console.log(chunkText);
248+
text += chunkText;
248249
}
249250

250251
// observe the output
@@ -362,8 +363,9 @@ mode: 'wide'
362363
let text = '';
363364

364365
for await (const chunk of readStream) {
365-
text += chunk;
366-
console.log(chunk);
366+
const chunkText = chunk.toString();
367+
console.log(chunkText);
368+
text += chunkText;
367369
}
368370

369371
// observe the output

docs/scripts/generatePages/jsTemplate.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ const readStream = await model.run(input, params, stream);
3131
let text = '';
3232

3333
for await (const chunk of readStream) {
34-
text += chunk;
35-
console.log(chunk);
34+
const chunkText = chunk.toString();
35+
console.log(chunkText);
36+
text += chunkText;
3637
}
3738

3839
// observe the output

0 commit comments

Comments
 (0)