Comments (3)
Oh I found the solution. You need to import openai-streams/node
and await the response. Now I am able to retrive the chunks of the stream.
import { OpenAI } from "openai-streams/node";
const stream = await OpenAI(
"chat",
{ model: "gpt-3.5-turbo", messages: [{ role: "user", content: "my question ..." }] },
{ apiKey: "" }
);
stream.on("data", (data) => {
console.log("DATA:", data);
});
stream.on("end", () => {
console.log("STREAM END");
});
from openai-streams.
@joni1802 I am seeing Module '"openai-streams/node"' has no exported member 'OpenAI'.
Are you using ESM in your project?
from openai-streams.
@mattgi Yes I am using ESM in my project and using node version v20.0.0
. I had no problem importing the module.
from openai-streams.
Related Issues (20)
- Abort streams HOT 2
- Function TokenParser HOT 4
- lol HOT 1
- use error HOT 1
- Error [ERR_REQUIRE_ESM]: require() of ES Module HOT 2
- Some tokens are being dropped HOT 4
- Error: TypeError: fetch failed HOT 1
- A question about onDone callback HOT 4
- gpt4 access HOT 1
- Is it possible cancel a stream HOT 3
- Hi, you can use `publint` to check publish package errors HOT 3
- No named export 'OpenAI' from 'openai-streams/node' HOT 2
- Module build failed: UnhandledSchemeError: Reading from "node:fs" is not handled by plugins (Unhandled scheme). HOT 4
- Error [ERR_REQUIRE_ESM]: require() of ES Module HOT 1
- No fetch implementation found HOT 14
- This package fails with `node --loader tsx`
- Support for function calling HOT 1
- How to support `continue generating` response
- ESM Support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openai-streams.