Skip to content

Commit e002451

Browse files
committed
updating code
1 parent b2f51c5 commit e002451

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

articles/ai-services/openai/includes/use-your-data-javascript.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,18 @@ async function main(){
6868
],
6969
},
7070
});
71+
let response = "";
7172
for await (const event of events) {
7273
for (const choice of event.choices) {
73-
const delta = choice.delta?.content;
74-
if (delta !== undefined) {
75-
console.log(`Chatbot: ${delta}`);
74+
const newText = choice.delta?.content;
75+
if (!!newText) {
76+
response += newText;
77+
// To see streaming results as they arrive, uncomment line below
78+
// console.log(newText);
7679
}
7780
}
7881
}
82+
console.log(chatGptAnswer);
7983
}
8084

8185
main().catch((err) => {

0 commit comments

Comments
 (0)