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

Text

Streams text from a given prompt.

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

Examples

import {  } from '@xsai/stream-text'
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 : string[] = []
 
for await (const  of ) {
  .()
}
 
// "The quick brown fox jumps over the lazy dog."
.()
Edit on GitHub

Last updated on

On this page