Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update availability values and add "downloading" #79

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,19 +351,20 @@ However, if the web developer wants to provide a differentiated user experience,

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

* "`no`" means that the implementation does not support the requested options, or does not support prompting a language model at all.
* "`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.
* "`readily`" means that the implementation supports the requested options without requiring any new downloads.
* "`unavailable`" means that the implementation does not support the requested options, or does not support prompting a language model at all.
* "`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.
* "`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.
* "`available`" means that the implementation supports the requested options without requiring any new downloads.

An example usage is the following:

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

const supportsOurUseCase = await ai.languageModel.availability(options);
const availability = await ai.languageModel.availability(options);

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

Expand Down Expand Up @@ -433,7 +434,7 @@ interface AICreateMonitor : EventTarget {

callback AICreateMonitorCallback = undefined (AICreateMonitor monitor);

enum AICapabilityAvailability { "readily", "after-download", "no" };
enum AIAvailability { "unavailable", "downloadable", "downloading", "available" };
```

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

Expand Down