Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
openai-streams
Advanced tools
This library returns OpenAI API responses as streams only. Non-stream endpoints
like edits
etc. are simply a stream with only one chunk update.
It simplifies the following:
OPENAI_API_KEY
from process.env
.OpenAI(endpoint, ...)
signature.Overall, the library aims to make it as simple to call the API as possible and stream updates in.
yarn add openai-streams
# or
npm i --save openai-streams
Set the OPENAI_API_KEY
env variable (or pass the { envKey }
option).
The library will throw if it cannot find an API key. Your program will load
this at runtime from process.env.OPENAI_API_KEY
by default, but you may
override which environment variable is loaded with the envKey
option.
await OpenAI(
"completions",
{/* ... */},
{ envKey: "MY_SECRET_OPENAI_KEY" }
)
Call the API via await OpenAI(endpoint, params)
.
The params
type will be inferred based on the endpoint
you provide, i.e.
for the "edits"
endpoint, import('openai').CreateEditRequest
will be
enforced.
import { OpenAI } from "openai-streams";
export default async function test() {
const stream = await OpenAI(
"completions",
{
model: "text-davinci-003",
prompt: "Write a two-sentence paragraph.\n\n",
temperature: 1,
max_tokens: 100,
// apiKey: "abc123",
},
);
return new Response(completionsStream);
}
for await (const chunk of yieldStream(stream)) { ... }
. We recommend following this
pattern if you find it intuitive.FAQs
Tools for working with OpenAI streams in Node.js and TypeScript.
The npm package openai-streams receives a total of 252 weekly downloads. As such, openai-streams popularity was classified as not popular.
We found that openai-streams demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.