Skip to content

Commit e9b3cec

Browse files
committed
fix: Stream examples
1 parent a6cc7ea commit e9b3cec

File tree

1 file changed

+0
-19
lines changed

1 file changed

+0
-19
lines changed

examples/studio/chat/stream-chat-completions.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
<<<<<<<< HEAD:src/examples/chatExample.ts
2-
import { AI21 } from '../AI21';
3-
4-
/*
5-
This is a temporary example to test the API streaming/non-streaming functionality.
6-
*/
7-
========
81
import { AI21 } from 'ai21';
92

10-
>>>>>>>> 61d25ea (docs: Added examples):examples/studio/chat/stream-chat-completions.ts
113
async function main() {
124
const client = new AI21({ apiKey: process.env.AI21_API_KEY });
135

146
try {
15-
console.log('-------------------------------- streaming flow --------------------------------');
16-
177
const streamResponse = await client.chat.completions.create({
188
model: 'jamba-1.5-mini',
199
messages: [{ role: 'user', content: 'Hello, how are you? tell me a 100 line story about a cat' }],
@@ -22,15 +12,6 @@ async function main() {
2212
for await (const chunk of streamResponse) {
2313
process.stdout.write(chunk.choices[0]?.delta?.content || '');
2414
}
25-
26-
console.log('-------------------------------- non streaming flow --------------------------------');
27-
28-
const response = await client.chat.completions.create({
29-
model: 'jamba-1.5-mini',
30-
messages: [{ role: 'user', content: 'Hello, how are you? tell me a 100 line story about a cat' }],
31-
stream: false,
32-
});
33-
console.log(response);
3415
} catch (error) {
3516
console.error('Error:', error);
3617
}

0 commit comments

Comments
 (0)