openai-streams
Advanced tools
Comparing version 1.0.22-canary.11 to 1.0.22-canary.13
@@ -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> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64927
1848
115