Utils
Stream
npm i @xsai/utils-streamExamples
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 { } = ({
: .!,
: '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 = ()