xsAI v0.1 is now available! Read Announcement
xsAI0.2.0-beta.1
Utils

Stream

install sizeminified sizeminzipped size
npm i @xsai/utils-stream

Examples

simulateReadableStream

import {  } from '@xsai/utils-stream'
 
const  = <number>({
  : [1, 2, 3],
  : 100,
  : 0,
})

smoothStream

import {  } from '@xsai/stream-text'
import {  } from '@xsai/utils-stream'
import {  } from 'node:process'
 
const {  } = await ({
  : .!,
  : 'https://api.openai.com/v1/',
  : [
    {
      : 'You are a helpful assistant.',
      : 'system',
    },
    {
      : 'This is a test, so please answer'
        + '\'The quick brown fox jumps over the lazy dog.\''
        + 'and nothing else.',
      : 'user',
    },
  ],
  : 'gpt-4o',
})
 
const  = .(({
  : 20,
  : 'line',
}))

toAsyncIterator

Simple polyfill for Safari. (see https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream#browser_compatibility)

import { ,  } from '@xsai/utils-stream'
 
const  = <number>({
  : [1, 2, 3],
  : 100,
  : 0,
})
 
const  = ()
Edit on GitHub

Last updated on

On this page