UNPKG

@llumiverse/core

Version:

Provide an universal API to LLMs. Support for existing LLMs can be added by writing a driver.

24 lines 949 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.readStreamAsBase64 = readStreamAsBase64; exports.readStreamAsString = readStreamAsString; exports.readStreamAsUint8Array = readStreamAsUint8Array; async function readStreamAsBase64(stream) { return (await _readStreamAsBuffer(stream)).toString('base64'); } async function readStreamAsString(stream) { return (await _readStreamAsBuffer(stream)).toString(); } async function readStreamAsUint8Array(stream) { // We return a Uint8Array for strict type checking, even though the buffer extends Uint8Array. const buffer = await _readStreamAsBuffer(stream); return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength); } async function _readStreamAsBuffer(stream) { const out = []; for await (const chunk of stream) { out.push(Buffer.from(chunk)); } return Buffer.concat(out); } //# sourceMappingURL=stream.js.map