LanguageModelFactory

Methods

capabilities

async capabilities(options) =>LanguageModelCapabilities

Get the capabilities of the on-device language model.

Options (optional)

model extension web optional string The id of the model to use, undefined to use the default. The extension version also accepts a direct link to a HuggingFace GGUF file. The web version also accepts the repo & name of a HuggingFace ONNX repo.

Returns a new capabilities object


create

async create(options) => LanguageModel

Creates a new language model session

Options (optional)

model extension web optional string

systemPrompt optional string

initialPrompts optional InitialPrompt[] An array of prompts each in the format

[
  { content: "The prompt content", role: "system" },
  { content: "The prompt content", role: "user" },
  { content: "The prompt content", role: "assistant" }
]

topK optional number

topP optional number

temperature optional number

repeatPenality optional number

flashAttention optional boolean

contextSize optional number

maxTokens optional number

grammar extension optional any

signal optional AbortSignal

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

Last updated