edgewise v0.4.1

Errors

Every error Edgewise throws is an EdgewiseError with a stable code, a message, and usually a hint that says what to do. retryable is true when trying again may work.

ts
import { EdgewiseError, UnsupportedInputError } from 'edgewise';

try {
  await generate({ model: 'text:default', input: [photo, 'What is this?'] });
} catch (err) {
  if (err instanceof UnsupportedInputError) console.log(err.hint); // '"lfm2.5-350m" accepts text. Try "lfm2.5-vl-450m" for image input.'
  if (err instanceof EdgewiseError && err.retryable) retryLater();
}
ClassCodeWhen
UnsupportedInputErrorE_INPUTthe model does not accept this input type, or a question type
UnsupportedDeviceErrorE_UNSUPPORTEDthe device cannot run the model (no WebGPU, browser-only API)
ModelNotFoundErrorE_MODELunknown model ID or alias, or a preview model without allowPreview
WrongVerbErrorE_VERBa model used with the wrong verb, such as an embed model in generate
DownloadErrorE_DOWNLOADa network failure, a bad status, or a SHA-256 mismatch (retryable is true except for 4xx statuses)
StorageQuotaErrorE_QUOTAthe browser refused to store the model
OutOfMemoryErrorE_OOMthe GPU or process ran out of memory; try a smaller model or dtype
BackendErrorE_BACKENDONNX Runtime failed to load or run the model
SchemaValidationErrorE_SCHEMAthe output did not match the schema after a retry; has raw and issues
PermissionErrorE_PERMISSIONthe user blocked the microphone
AbortErrorE_ABORTthe signal fired or cancel() was called
ConfigErrorE_CONFIGinvalid options

Fallbacks#

ts
configure({
  fallback: {
    onUnsupported: 'next-variant', // or 'throw': try the next device instead of failing
    onBackendError: 'cpu',         // or 'throw': reload on the CPU path when a Transformers.js model fails to load on the GPU
  },
});

info.device in every result tells you whether a fallback happened. With configure({ debug: true }) Edgewise logs each decision.

Edgewise 0.4.1 · MIT licence · Edit this page