Skip to content

Commit 5ea57ac

Browse files
committed
fix chat example
1 parent 33ee9fb commit 5ea57ac

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

examples/chatCompletions.example.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ async function streamingExample() {
6666
let fullContent = "";
6767

6868
for await (const chunk of stream) {
69-
if (chunk.data.choices && chunk.data.choices[0]?.delta?.content) {
70-
const content = chunk.data.choices[0].delta.content;
69+
if (chunk.choices && chunk.choices[0]?.delta?.content) {
70+
const content = chunk.choices[0].delta.content;
7171
process.stdout.write(content);
7272
fullContent += content;
7373
}
7474

75-
if (chunk.data.usage) {
76-
console.log("\n\nStream usage:", chunk.data.usage);
75+
if (chunk.usage) {
76+
console.log("\n\nStream usage:", chunk.usage);
7777
}
7878
}
7979

0 commit comments

Comments
 (0)