Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

openai-streams

Package Overview
Dependencies
Maintainers
1
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openai-streams - npm Package Compare versions

Comparing version 1.0.22-canary.11 to 1.0.22-canary.13

node.d.ts

2

dist/lib/openai/index.d.ts

@@ -1,1 +0,1 @@

export * from "./node";
export * from "./edge";

@@ -1,1 +0,1 @@

export*from"./node.js";
export*from"./edge.js";

@@ -7,3 +7,5 @@ import { OpenAINodeClient } from "../types";

* 'raw'` for the raw stream of JSON objects.
*
* @note Use `openai-streams/edge` for Edge Runtime or Browser.
*/
export declare const OpenAI: OpenAINodeClient;
{
"name": "openai-streams",
"description": "Tools for working with OpenAI streams in Node.js and TypeScript.",
"version": "1.0.22-canary.11",
"version": "1.0.22-canary.13",
"license": "MIT",

@@ -14,8 +14,8 @@ "type": "module",

"dist",
"edge.js",
"edge.d.ts"
"node.js",
"node.d.ts"
],
"exports": {
"./package.json": "./package.json",
"./edge": "./edge.js",
"./node": "./node.js",
".": "./dist/index.js",

@@ -22,0 +22,0 @@ "./*": "./dist/*/index.js"

@@ -57,3 +57,5 @@ # OpenAI Streams

### Example: Consuming streams using Next.js API Route (Node)
#### Example: Consuming streams in Next.js Edge functions
```ts

@@ -63,3 +65,3 @@ import { OpenAI } from "openai-streams";

export default async function handler() {
const stream = await OpenAI.Node(
const stream = await OpenAI(
"completions",

@@ -73,10 +75,18 @@ {

stream.pipe(res);
return new Response(stream);
}
export const config = {
runtime: "edge"
};
```
#### Example: Consuming streams in Next.js Edge functions
### Example: Consuming streams using Next.js API Route (Node)
If you cannot use an Edge runtime or want to consume Node.js streams for another
reason, use `openai-streams/node`:
```ts
import { OpenAI } from "openai-streams";
import { OpenAI } from "openai-streams/node";

@@ -93,10 +103,7 @@ export default async function handler() {

return new Response(stream);
stream.pipe(res);
}
export const config = {
runtime: "edge"
};
```
<sub>See the example in

@@ -103,0 +110,0 @@ [`example/src/pages/api/hello.ts`](https://github.com/gptlabs/openai-streams/blob/master/src/pages/api/hello.ts).</sub>

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc