Created
March 17, 2023 02:48
-
-
Save transmissions11/87ab124ebd85823b1565c4110836c7f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { OpenAI } from "openai-streams"; | |
import { yieldStream } from "yield-stream"; | |
const stream = await OpenAI( | |
"chat", | |
{ | |
model: "gpt-3.5-turbo", | |
n: 2, | |
temperature: 1, | |
messages: [{ role: "user", content: "hi" }], | |
}, | |
{ apiKey: API_KEY, mode: "raw" } | |
); | |
const DECODER = new TextDecoder(); | |
for await (const chunk of yieldStream(stream)) { | |
const decoded = JSON.parse(DECODER.decode(chunk)); | |
console.log(decoded); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output ends with this weird error object