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 3.0.3 to 3.1.0

dist/lib/errors.d.ts

2

dist/lib/streaming/streams.js

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

import{ENCODER as m,DECODER as p}from"../../globs/shared.js";import{TokenParser as i}from"./transforms.js";import{createParser as s}from"eventsource-parser";import{pipeline as c,yieldStream as S}from"yield-stream";const d=r=>new ReadableStream({async start(t){const n=s(e=>{if(e.type==="event"){const{data:a}=e;if(a==="[DONE]"){t.close();return}try{JSON.parse(a),t.enqueue(m.encode(a))}catch(o){t.error(o)}}});for await(const e of S(r))n.feed(p.decode(e))}}),A=r=>c(d(r),i);export{d as EventStream,A as TokenStream};
import{ENCODER as c,DECODER as m}from"../../globs/shared.js";import{TokenParser as p}from"./transforms.js";import{createParser as f}from"eventsource-parser";import{pipeline as S,yieldStream as d}from"yield-stream";import{OpenAIError as O}from"../errors.js";const h=t=>new ReadableStream({async start(a){const n=f(e=>{if(e.type==="event"){const{data:o}=e;if(o==="[DONE]"){a.close();return}try{a.enqueue(c.encode(o));const r=JSON.parse(o);if(r?.choices){const{choices:i}=r;for(const s of i)if(s?.finish_reason==="length")throw new O("MAX_TOKENS")}}catch(r){a.error(r)}}});for await(const e of d(t))n.feed(m.decode(e))}}),w=t=>S(h(t),p);export{h as EventStream,w as TokenStream};
{
"name": "openai-streams",
"description": "Tools for working with OpenAI streams in Node.js and TypeScript.",
"version": "3.0.3",
"version": "3.1.0",
"license": "MIT",

@@ -29,4 +29,4 @@ "type": "module",

"postbuild": "yarn docs",
"test": "ava",
"pretest": "yarn build",
"test": "yarn build && ava",
"retest": "ava",
"prepublishOnly": "yarn test",

@@ -33,0 +33,0 @@ "lint": "eslint src --fix"

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