We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bf72a08 commit 872f74cCopy full SHA for 872f74c
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