Spaces:
Sleeping
Sleeping
| import { OpenAI } from "openai"; | |
| const client = new OpenAI({ | |
| baseURL: "http://localhost:4040/fireworks-ai/inference/v1", | |
| apiKey: process.env.HF_API_KEY, | |
| }); | |
| let out = ""; | |
| const stream = await client.chat.completions.create({ | |
| model: "accounts/fireworks/models/deepseek-v3", | |
| messages: [ | |
| { | |
| role: "user", | |
| content: "What is the capital of France?", | |
| }, | |
| ], | |
| stream: true, | |
| max_tokens: 500, | |
| }); | |
| for await (const chunk of stream) { | |
| if (chunk.choices && chunk.choices.length > 0) { | |
| const newContent = chunk.choices[0].delta.content; | |
| out += newContent; | |
| console.log(newContent); | |
| } | |
| } | |