We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 46e8eb6 commit a3fc659Copy full SHA for a3fc659
examples/tool-calls-stream.ts
@@ -27,6 +27,9 @@ import {
27
ChatCompletionMessageParam,
28
} from 'openai/resources/chat';
29
30
+// Used so that the each chunk coming in is noticable
31
+const CHUNK_DELAY_MS = 100;
32
+
33
// gets API Key from environment variable OPENAI_API_KEY
34
const openai = new OpenAI();
35
@@ -126,6 +129,9 @@ async function main() {
126
129
for await (const chunk of stream) {
127
130
message = messageReducer(message, chunk);
128
131
writeLine(message);
132
133
+ // Add a small delay so that the chunks coming in are noticablej
134
+ await new Promise((resolve) => setTimeout(resolve, CHUNK_DELAY_MS));
135
}
136
console.log();
137
messages.push(message);
0 commit comments