๐Ÿ“ฆ Kong / volcano-sdk

๐Ÿ“„ 03-streaming.ts ยท 19 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19import { agent, llmOpenAI } from "../dist/volcano-sdk.js";

const llm = llmOpenAI({ 
  apiKey: process.env.OPENAI_API_KEY!, 
  model: "gpt-4o-mini" 
});

console.log("Story streaming in real-time:\n");

await agent({ llm })
  .then({ 
    prompt: "Write a short story about a robot learning to paint",
    onToken: (token) => process.stdout.write(token)
  })
  .run();

console.log("\n\nDone!");