Definition
Prompt API defines LanguageModel
[Exposed=Window, SecureContext]
interface LanguageModel : EventTarget {
static Promise<LanguageModel> create(optional LanguageModelCreateOptions options = {});
static Promise<Availability> availability(optional LanguageModelCreateCoreOptions options = {});
// **EXPERIMENTAL**: Only available in extension and experimental contexts.
static Promise<LanguageModelParams?> params();
// These will throw "NotSupportedError" DOMExceptions if role = "system"
Promise<DOMString> prompt(
LanguageModelPrompt input,
optional LanguageModelPromptOptions options = {}
);
ReadableStream promptStreaming(
LanguageModelPrompt input,
optional LanguageModelPromptOptions options = {}
);
Promise<undefined> append(
LanguageModelPrompt input,
optional LanguageModelAppendOptions options = {}
);
Promise<double> measureContextUsage(
LanguageModelPrompt input,
optional LanguageModelPromptOptions options = {}
);
readonly attribute double contextUsage;
readonly attribute unrestricted double contextWindow;
attribute EventHandler oncontextoverflow;
// **DEPRECATED**: This method is only available in extension contexts.
Promise<double> measureInputUsage(
LanguageModelPrompt input,
optional LanguageModelPromptOptions options = {}
);
// **DEPRECATED**: This attribute is only available in extension contexts.
readonly attribute double inputUsage;
// **DEPRECATED**: This attribute is only available in extension contexts.
readonly attribute unrestricted double inputQuota;
// **DEPRECATED**: This attribute is only available in extension contexts.
attribute EventHandler onquotaoverflow;
// **EXPERIMENTAL**: Only available in extension and experimental contexts.
readonly attribute unsigned long topK;
// **EXPERIMENTAL**: Only available in extension and experimental contexts.
readonly attribute float temperature;
Promise<LanguageModel> clone(optional LanguageModelCloneOptions options = {});
};
LanguageModel includes DestroyableModel;
Consolidated IDL (across mixin and partials)
[Exposed=Window, SecureContext]
interface LanguageModel : EventTarget {
static Promise<LanguageModel> create(optional LanguageModelCreateOptions options = {});
static Promise<Availability> availability(optional LanguageModelCreateCoreOptions options = {});
// **EXPERIMENTAL**: Only available in extension and experimental contexts.
static Promise<LanguageModelParams?> params();
// These will throw "NotSupportedError" DOMExceptions if role = "system"
Promise<DOMString> prompt(
LanguageModelPrompt input,
optional LanguageModelPromptOptions options = {}
);
ReadableStream promptStreaming(
LanguageModelPrompt input,
optional LanguageModelPromptOptions options = {}
);
Promise<undefined> append(
LanguageModelPrompt input,
optional LanguageModelAppendOptions options = {}
);
Promise<double> measureContextUsage(
LanguageModelPrompt input,
optional LanguageModelPromptOptions options = {}
);
readonly attribute double contextUsage;
readonly attribute unrestricted double contextWindow;
attribute EventHandler oncontextoverflow;
// **DEPRECATED**: This method is only available in extension contexts.
Promise<double> measureInputUsage(
LanguageModelPrompt input,
optional LanguageModelPromptOptions options = {}
);
// **DEPRECATED**: This attribute is only available in extension contexts.
readonly attribute double inputUsage;
// **DEPRECATED**: This attribute is only available in extension contexts.
readonly attribute unrestricted double inputQuota;
// **DEPRECATED**: This attribute is only available in extension contexts.
attribute EventHandler onquotaoverflow;
// **EXPERIMENTAL**: Only available in extension and experimental contexts.
readonly attribute unsigned long topK;
// **EXPERIMENTAL**: Only available in extension and experimental contexts.
readonly attribute float temperature;
Promise<LanguageModel> clone(optional LanguageModelCloneOptions options = {});
undefined destroy();
};