Skip to content

Commit 618d4e5

Browse files
committed
Add a permissions policy and remove worker support
1 parent a3d94bd commit 618d4e5

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ All of the above examples have been of text prompts. Some language models also s
185185

186186
* For audio inputs: for now, `Blob`, `AudioBuffer`, or raw bytes via `BufferSource`. Other possibilities we're investigating include `HTMLAudioElement`, `AudioData`, and `MediaStream`, but we're not yet sure if those are suitable to represent "clips": most other uses of them on the web platform are able to handle streaming data.
187187

188-
Sessions that will include these inputs need to be created using the `expectedInputs` option, to ensure that any necessary downloads are done as part of session creation, and that if the model is not capable of such multimodal prompts, the session creation fails. (See also the below discussion of [expected input languages](#multilingual-content-and-expected-languages), not just expected input types.)
188+
Sessions that will include these inputs need to be created using the `expectedInputs` option, to ensure that any necessary downloads are done as part of session creation, and that if the model is not capable of such multimodal prompts, the session creation fails. (See also the below discussion of [expected input languages](#multilingual-content-and-expected-input-languages), not just expected input types.)
189189

190190
A sample of using these APIs:
191191

@@ -688,7 +688,7 @@ Finally, note that there is a sort of precedent in the (never-shipped) [`FetchOb
688688
### Full API surface in Web IDL
689689

690690
```webidl
691-
[Exposed=(Window,Worker), SecureContext]
691+
[Exposed=Window, SecureContext]
692692
interface LanguageModel : EventTarget {
693693
static Promise<LanguageModel> create(optional LanguageModelCreateOptions options = {});
694694
static Promise<Availability> availability(optional LanguageModelCreateCoreOptions options = {});
@@ -723,7 +723,7 @@ interface LanguageModel : EventTarget {
723723
undefined destroy();
724724
};
725725
726-
[Exposed=(Window,Worker), SecureContext]
726+
[Exposed=Window, SecureContext]
727727
interface LanguageModelParams {
728728
readonly attribute unsigned long defaultTopK;
729729
readonly attribute unsigned long maxTopK;
@@ -809,6 +809,18 @@ To illustrate the difference and how it impacts web developer expectations:
809809

810810
To ensure the API can be used by web developers across multiple implementations, all browsers should be sure their models behave like instruction-tuned models.
811811

812+
### Permissions policy, iframes, and workers
813+
814+
By default, this API is only available to top-level `Window`s, and to their same-origin iframes. Access to the API can be delegated to cross-origin iframes using the [Permissions Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Permissions_Policy) `allow=""` attribute:
815+
816+
```html
817+
<iframe src="https://example.com/" allow="language-model"></iframe>
818+
```
819+
820+
This API is currently not available in workers, due to the complexity of establishing a responsible document for each worker in order to check the permissions policy status. See [this discussion](https://github.com/webmachinelearning/translation-api/issues/18#issuecomment-2705630392) for more. It may be possible to loosen this restriction over time, if use cases arise.
821+
822+
Note that although the API is not exposed to web platform workers, a browser could expose them to extension service workers, which are outside the scope of web platform specifications and have a different permissions model.
823+
812824
## Alternatives considered and under consideration
813825

814826
### How many stages to reach a response?

0 commit comments

Comments
 (0)