Files
sousa-gecko/testing/web-platform/tests/interfaces/prompt-api.idl
T
github-actions[bot] 94f89476bd Bug 2048996 [wpt PR 60753] - Sync interfaces/ with @webref/idl 3.81.1, a=testonly
Automatic update from web-platform-tests
Sync interfaces/ with @webref/idl 3.81.1 (#60753)

Co-authored-by: wpt-pr-bot <wpt-pr-bot@users.noreply.github.com>
--

wpt-commits: 8c3a65eb65d581f58ab5af381ca94182ed8399b6
wpt-pr: 60753
2026-06-25 17:01:30 +00:00

154 lines
5.1 KiB
Plaintext

// GENERATED CONTENT - DO NOT EDIT
// Content was automatically extracted by Reffy into webref
// (https://github.com/w3c/webref)
// Source: Prompt API (https://webmachinelearning.github.io/prompt-api/)
[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;
readonly attribute LanguageModelSamplingMode samplingMode;
Promise<LanguageModel> clone(optional LanguageModelCloneOptions options = {});
};
LanguageModel includes DestroyableModel;
// **EXPERIMENTAL**: Only available in extension and experimental contexts.
[Exposed=Window, SecureContext]
interface LanguageModelParams {
readonly attribute unsigned long defaultTopK;
readonly attribute unsigned long maxTopK;
readonly attribute float defaultTemperature;
readonly attribute float maxTemperature;
};
callback LanguageModelToolFunction = Promise<DOMString> (any... arguments);
// A description of a tool call that a language model can invoke.
dictionary LanguageModelTool {
required DOMString name;
required DOMString description;
// JSON schema for the input parameters.
required object inputSchema;
// The function to be invoked by user agent on behalf of language model.
required LanguageModelToolFunction execute;
};
dictionary LanguageModelCreateCoreOptions {
// Note: these two have custom out-of-range handling behavior, not in the IDL layer.
// They are unrestricted double so as to allow +Infinity without failing.
// **EXPERIMENTAL**: Only available in extension and experimental contexts.
unrestricted double topK;
// **EXPERIMENTAL**: Only available in extension and experimental contexts.
unrestricted double temperature;
LanguageModelSamplingMode samplingMode = "default";
sequence<LanguageModelExpected> expectedInputs;
sequence<LanguageModelExpected> expectedOutputs;
sequence<LanguageModelTool> tools;
};
dictionary LanguageModelCreateOptions : LanguageModelCreateCoreOptions {
AbortSignal signal;
CreateMonitorCallback monitor;
sequence<LanguageModelMessage> initialPrompts;
};
dictionary LanguageModelPromptOptions {
object responseConstraint;
boolean omitResponseConstraintInput = false;
AbortSignal signal;
};
dictionary LanguageModelAppendOptions {
AbortSignal signal;
};
dictionary LanguageModelCloneOptions {
AbortSignal signal;
};
dictionary LanguageModelExpected {
required LanguageModelMessageType type;
sequence<DOMString> languages;
};
// The argument to the prompt() method and others like it
typedef (
sequence<LanguageModelMessage>
// Shorthand for `[{ role: "user", content: [{ type: "text", value: providedValue }] }]`
or DOMString
) LanguageModelPrompt;
dictionary LanguageModelMessage {
required LanguageModelMessageRole role;
// The DOMString branch is shorthand for `[{ type: "text", value: providedValue }]`
required (DOMString or sequence<LanguageModelMessageContent>) content;
boolean prefix = false;
};
dictionary LanguageModelMessageContent {
required LanguageModelMessageType type;
required LanguageModelMessageValue value;
};
enum LanguageModelSamplingMode { "most-predictable", "predictable", "balanced", "creative", "most-creative" };
enum LanguageModelMessageRole { "system", "user", "assistant" };
enum LanguageModelMessageType { "text", "image", "audio", "tool-call", "tool-response" };
typedef (
ImageBitmapSource
or AudioBuffer
or BufferSource
or DOMString
) LanguageModelMessageValue;