Skip to content

Commit 573760f

Browse files
authored
Update availability values and add "downloading"
See webmachinelearning/writing-assistance-apis#29.
1 parent 886259b commit 573760f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -351,19 +351,20 @@ However, if the web developer wants to provide a differentiated user experience,
351351

352352
The method will return a promise that fulfills with one of the following availability values:
353353

354-
* "`no`" means that the implementation does not support the requested options, or does not support prompting a language model at all.
355-
* "`after-download`" means that the implementation supports the requested options, but it will have to download something (e.g. the language model itself, or a fine-tuning) before it can create a session using those options.
356-
* "`readily`" means that the implementation supports the requested options without requiring any new downloads.
354+
* "`unavailable`" means that the implementation does not support the requested options, or does not support prompting a language model at all.
355+
* "`downloadable`" means that the implementation supports the requested options, but it will have to download something (e.g. the language model itself, or a fine-tuning) before it can create a session using those options.
356+
* "`downloading`" means that the implementation supports the requested options, but will need to finish an ongoing download operation before it can create a session using those options.
357+
* "`available`" means that the implementation supports the requested options without requiring any new downloads.
357358

358359
An example usage is the following:
359360

360361
```js
361362
const options = { expectedInputLanguages: ["en", "es"], temperature: 2 };
362363

363-
const supportsOurUseCase = await ai.languageModel.availability(options);
364+
const availability = await ai.languageModel.availability(options);
364365

365-
if (supportsOurUseCase !== "no") {
366-
if (supportsOurUseCase === "after-download") {
366+
if (availability !== "unavailable") {
367+
if (availability !== "available") {
367368
console.log("Sit tight, we need to do some downloading...");
368369
}
369370

@@ -433,7 +434,7 @@ interface AICreateMonitor : EventTarget {
433434
434435
callback AICreateMonitorCallback = undefined (AICreateMonitor monitor);
435436
436-
enum AICapabilityAvailability { "readily", "after-download", "no" };
437+
enum AIAvailability { "unavailable", "downloadable", "downloading", "available" };
437438
```
438439

439440
```webidl
@@ -442,7 +443,7 @@ enum AICapabilityAvailability { "readily", "after-download", "no" };
442443
[Exposed=(Window,Worker), SecureContext]
443444
interface AILanguageModelFactory {
444445
Promise<AILanguageModel> create(optional AILanguageModelCreateOptions options = {});
445-
Promise<AICapabilityAvailability> availability(optional AILanguageModelCreateCoreOptions options = {});
446+
Promise<AIAvailability> availability(optional AILanguageModelCreateCoreOptions options = {});
446447
Promise<AILanguageModelParams?> params();
447448
};
448449

0 commit comments

Comments
 (0)