Translator
Static Methods
static availability
static async availability(options) =>
AIModelAvailability
Get the availability of the on-device language model.
options TranslatorCreateOptions
Returns the availability
static compatibility extension web
static async compatibility(options) =>
AIModelCoreCompatibility
Get the availability of the on-device language model.
options TranslatorCreateOptions
Returns the compatibility
static create
static async create(options) =>
Translator
Creates a new embedding session
options TranslatorCreateOptions
Returns a new Translator session that can be prompted with the pre-provided configuration
Properties
gpuEngine extension web
dtype extension web
flashAttention extension web
boolean
contextSize
number
inputQuota
number
repeatPenalty extension web
number
sourceLanguage
string
targetLanguage
string
Methods
translate
async (input, options) => string
translateStreaming
(input, options) => ReadableStream
This prompts the language model to translate the provided text. The returned stream should contain the translation
A string
to be translated
signal optional AbortSignal
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
A string
signal optional AbortSignal
Returns prompt usage based on the input
Last updated