Prompt API: Align implementation with other Built-In AI APIs
Inline availability and create in static LanguageModel methods.
Encapsulate session creation logic in new LanguageModelCreateClient.
Remove LanguageModelFactory, AI, DOMAI, and helpers.
Remove explicit extension bindings code, consolidate runtime flags.
Limit origin trial to extension processes via OriginTrialContext.
Remove extension permission req and chrome.aiOriginTrial namespace.
Update tests.
Bug: 380962105, 381969447, 415018777, 416417900
Test: Automated; dev trial & extension OT still expose `LanguageModel`.
Change-Id: Ide3424a75f1a361e5f0f1ff9753b6a1dbc66f8fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6514300
Reviewed-by: Devlin Cronin <[email protected]>
Auto-Submit: Mike Wasserman <[email protected]>
Reviewed-by: Kelvin Jiang <[email protected]>
Reviewed-by: Mike West <[email protected]>
Reviewed-by: Brad Triebwasser <[email protected]>
Commit-Queue: Devlin Cronin <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1459532}
diff --git a/docs/experiments/prompt-api-for-extension.md b/docs/experiments/prompt-api-for-extension.md
index c75eb93..6e54178 100644
--- a/docs/experiments/prompt-api-for-extension.md
+++ b/docs/experiments/prompt-api-for-extension.md
@@ -14,12 +14,10 @@
The API can be enabled by participating in the
[extension origin trial](https://developer.chrome.com/blog/prompt-api-origin-trial)
named `AIPromptAPIForExtension`. After obtaining the trial token, the
-extension authors need to configure it in the `manifest.json` together with
-the `aiLanguageModelOriginTrial` permission.
+extension authors need to configure it in the `manifest.json`:
```json
{
- "permissions": ["aiLanguageModelOriginTrial"],
"trial_tokens": [<GENERATED_TOKEN>],
}
```
@@ -27,10 +25,10 @@
## Verifying the API is working
The extension authors can verify if the API is available by checking for the
-presence of `LanguageModel` or `chrome.aiOriginTrial.languageModel` entrypoints
-from extension window and worker scripts. If the object is defined, the authors
-can follow the [explainer](https://github.com/explainers-by-googlers/prompt-api)
-and [developer docs](https://developer.chrome.com/docs/extensions/ai/prompt-api)
+presence of the `LanguageModel` entrypoint from extension window and worker
+scripts. If the object is defined, the authors can follow the
+[explainer](https://github.com/explainers-by-googlers/prompt-api) and
+[developer docs](https://developer.chrome.com/docs/extensions/ai/prompt-api)
to check availability and test the APIs usage.
## Related Links