Rewriter

Static Methods

static availability

static async availability(options) => AIModelAvailability

Get the availability of the on-device language model.

Options (optional)

options optional RewriterCreateOptions

Returns the availability

static compatibility extension web

static async compatibility(options) => AIModelCoreCompatibility

Get the availability of the on-device language model.

Options (optional)

options optional RewriterCreateOptions

Returns the compatibility

static create

static async create(options) => Rewriter

Creates a new embedding session

Options (optional)

options optional RewriterCreateOptions

Returns a new Rewriter session that can be prompted with the pre-provided configuration


Properties

gpuEngine extension web

AIModelGpuEngine

dtype extension web

AIModelDtype

flashAttention extension web

boolean

contextSize

number

inputQuota

number

repeatPenalty extension web

number

sharedContext

string

tone

RewriterTone

format

RewriterFormat

length

RewriterLength

expectedInputLanguages

string[]

expectedContextLanguages

string[]


Methods

rewrite

async (input, options) => string

See rewriteStreaming

rewriteStreaming

(input, options) => ReadableStream

This prompts the model to rewrite the given input and session options.

Input

A stringcontaining the text to rewrite

Options (optional)

signal optional AbortSignal

context optional string

Returns a readable stream that updates each time new tokens are available from the language model

measureInputUsage

async (input, options) => number

Measures the prompt usage of the input

Input

A string

Options (optional)

signal optional AbortSignal

Returns prompt usage based on the input

Last updated