// 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 create(optional LanguageModelCreateOptions options = {}); static Promise availability(optional LanguageModelCreateCoreOptions options = {}); // **EXPERIMENTAL**: Only available in extension and experimental contexts. static Promise params(); // These will throw "NotSupportedError" DOMExceptions if role = "system" Promise prompt( LanguageModelPrompt input, optional LanguageModelPromptOptions options = {} ); ReadableStream promptStreaming( LanguageModelPrompt input, optional LanguageModelPromptOptions options = {} ); Promise append( LanguageModelPrompt input, optional LanguageModelAppendOptions options = {} ); Promise 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 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 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 (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; sequence expectedInputs; sequence expectedOutputs; sequence tools; }; dictionary LanguageModelCreateOptions : LanguageModelCreateCoreOptions { AbortSignal signal; CreateMonitorCallback monitor; sequence initialPrompts; }; dictionary LanguageModelPromptOptions { object responseConstraint; boolean omitResponseConstraintInput = false; AbortSignal signal; }; dictionary LanguageModelAppendOptions { AbortSignal signal; }; dictionary LanguageModelCloneOptions { AbortSignal signal; }; dictionary LanguageModelExpected { required LanguageModelMessageType type; sequence languages; }; // The argument to the prompt() method and others like it typedef ( sequence // 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) content; boolean prefix = false; }; dictionary LanguageModelMessageContent { required LanguageModelMessageType type; required LanguageModelMessageValue value; }; enum LanguageModelMessageRole { "system", "user", "assistant" }; enum LanguageModelMessageType { "text", "image", "audio", "tool-call", "tool-response" }; typedef ( ImageBitmapSource or AudioBuffer or BufferSource or DOMString ) LanguageModelMessageValue;