-
Notifications
You must be signed in to change notification settings - Fork 20
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
Making capabilities() API a factory #67
Comments
To be clear, it's not the case that we expect web developers to always call Given this, it sounds like you're suggesting that instead of the implementation caching, we should make the developer do this work? I feel like it would be better for the implementation to transparently cache, to keep the current API for developers so that they don't have to do this two-step process. |
Thanks, I got the point that the capabilities API is used to provide extra info but not supposed to block the creation. It's perfectly fine if the developer doesn't care about the capabilities and just want to create a session straightaway. There is another case that was raised during the discussion: if the model/metadata has changed between calling For example, they only want to download the model when Japanese is supported, this is what they might do const capabilities = await ai.languageModel.capabilities();
if (capabilities.available !== "no" && capabilities.languageAvailable("ja") !== "no") {
// at this point the model is changed, and ja support is removed
const session = await ai.languageModel.create();
// this session doesn't support Japanese!
} In this case if the create method is called from the capabilities then the version mismatch can be detected and we could throw a clear error indicating that the mode file has been updated, and the developer need to be retry the I agree that this is a extreme corner case though. |
In that case |
We are expecting the developers to call
capabilities()
before creating theAILanguageModel
but currently this dependency is not enforced, when actually creating the model, it's still necessary to run the availability check.Would it be better if the
capabilities()
API returns a factory, which will only be set when the availability isreadily
orafter-download
, and we move thecreate()
method to the factory?The usage becomes:
The text was updated successfully, but these errors were encountered: