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

Add Chrome AI as a Provider for our text generation Features #819

Merged
merged 20 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
81be83e
Initial implementation of the Chrome AI API with the excerpt generati…
dkotter Oct 15, 2024
3420cda
Add support for generating titles using Chrome AI
dkotter Oct 15, 2024
6e579c9
Add support for content resizing using Chrome AI
dkotter Oct 15, 2024
9b97859
Move our Chrome AI JS code into a JS file instead of rendering that i…
dkotter Oct 16, 2024
929a15d
Ensure the AI method we need is available so an error isn't thrown
dkotter Oct 16, 2024
cd7514c
Merge branch 'develop' into feature/chrome-ai
dkotter Oct 16, 2024
3457370
Fix title generation
dkotter Oct 16, 2024
8d3c9a7
Merge branch 'develop' into feature/chrome-ai
dkotter Nov 19, 2024
09c3298
Merge branch 'develop' into feature/chrome-ai
dkotter Dec 10, 2024
55c9b37
Merge branch 'develop' of github.com:10up/classifai into feature/chro…
iamdharmesh Dec 12, 2024
48cdc20
Merge branch 'develop' of github.com:10up/classifai into feature/chro…
iamdharmesh Dec 16, 2024
24c4536
Merge branch 'develop' into feature/chrome-ai
dkotter Dec 16, 2024
9592b72
Trim the content we send to ChromeAI to stay under the token limit
dkotter Dec 16, 2024
2d9c8b3
Add some error messages if AI isn't available or doesn't work properly
dkotter Dec 16, 2024
cf1131f
Update how "Chrome AI" provider handled in settings.
iamdharmesh Dec 16, 2024
5c1aa48
Remove the Chrome AI Provider if on a browser that doesn't support it…
dkotter Dec 16, 2024
0942a85
Merge branch 'feature/chrome-ai' of github.com:10up/classifai into fe…
dkotter Dec 16, 2024
93d2a54
Move create session in try/catch block.
iamdharmesh Dec 17, 2024
7752553
Merge branch 'develop' into feature/chrome-ai
dkotter Dec 17, 2024
2f0d605
Add an experimental label to the Provider
dkotter Dec 17, 2024
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
12 changes: 12 additions & 0 deletions hookdocs/chrome-built-in-ai.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Chrome is experimenting with adding [built-in AI](https://developer.chrome.com/docs/ai/built-in) directly to the browser, allowing websites and web applications to perform AI-powered tasks without needing to deploy or manage their own AI models. Please follow the steps below to use Chrome’s built-in AI:

1. **Install Chrome Canary:** Ensure you have version v128.0.6545.0 or newer.
2. **Enable Optimization Guide:** Open `chrome://flags/#optimization-guide-on-device-model`, set it to "Enabled BypassPerfRequirement".
3. **Enable Prompt API:** Open `chrome://flags/#prompt-api-for-gemini-nano`, set it to "Enabled".
4. **Relaunch Chrome**.
5. **Open DevTools** and send `await ai.languageModel.capabilities().available;` in the console. If this returns “readily,” then you are all set.
6. **If it fails**, force Chrome to recognize that you want to use this API. To do so, open DevTools and send `await ai.languageModel.create();` in the console. This will likely fail, but it’s intended.
7. **Relaunch Chrome**.
8. **Open a new tab in Chrome**, go to `chrome://components`.
9. **Confirm** that Gemini Nano is either available or is being downloaded. You'll want to see the Optimization Guide On Device Model present with a version greater or equal to 2024.5.21.1031. If there is no version listed, click on "Check for update" to force the download.
10. **Once the model has downloaded and has reached a version greater than shown above**, open DevTools and send `await ai.languageModel.capabilities().available;` in the console. If this returns “readily,” then you are all set.
3 changes: 3 additions & 0 deletions hookdocs/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
},
"prompt-examples": {
"title": "Prompt examples"
},
"chrome-built-in-ai": {
"title": "Chrome built-in AI"
}
}
2 changes: 2 additions & 0 deletions includes/Classifai/Features/ContentResizing.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Classifai\Providers\Azure\OpenAI;
use Classifai\Providers\GoogleAI\GeminiAPI;
use Classifai\Providers\OpenAI\ChatGPT;
use Classifai\Providers\Browser\ChromeAI;
use Classifai\Services\LanguageProcessing;
use WP_REST_Server;
use WP_REST_Request;
Expand Down Expand Up @@ -52,6 +53,7 @@ public function __construct() {
ChatGPT::ID => __( 'OpenAI ChatGPT', 'classifai' ),
GeminiAPI::ID => __( 'Google AI (Gemini API)', 'classifai' ),
OpenAI::ID => __( 'Azure OpenAI', 'classifai' ),
ChromeAI::ID => __( 'Chrome AI (experimental)', 'classifai' ),
];
}

Expand Down
2 changes: 2 additions & 0 deletions includes/Classifai/Features/ExcerptGeneration.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Classifai\Providers\GoogleAI\GeminiAPI;
use Classifai\Providers\OpenAI\ChatGPT;
use Classifai\Providers\Azure\OpenAI;
use Classifai\Providers\Browser\ChromeAI;
use WP_REST_Server;
use WP_REST_Request;
use WP_Error;
Expand Down Expand Up @@ -45,6 +46,7 @@ public function __construct() {
ChatGPT::ID => __( 'OpenAI ChatGPT', 'classifai' ),
GeminiAPI::ID => __( 'Google AI (Gemini API)', 'classifai' ),
OpenAI::ID => __( 'Azure OpenAI', 'classifai' ),
ChromeAI::ID => __( 'Chrome AI (experimental)', 'classifai' ),
];
}

Expand Down
2 changes: 2 additions & 0 deletions includes/Classifai/Features/TitleGeneration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Classifai\Providers\Azure\OpenAI;
use Classifai\Providers\GoogleAI\GeminiAPI;
use Classifai\Providers\OpenAI\ChatGPT;
use Classifai\Providers\Browser\ChromeAI;
use Classifai\Services\LanguageProcessing;
use WP_REST_Server;
use WP_REST_Request;
Expand Down Expand Up @@ -45,6 +46,7 @@ public function __construct() {
ChatGPT::ID => __( 'OpenAI ChatGPT', 'classifai' ),
GeminiAPI::ID => __( 'Google AI (Gemini API)', 'classifai' ),
OpenAI::ID => __( 'Azure OpenAI', 'classifai' ),
ChromeAI::ID => __( 'Chrome AI (experimental)', 'classifai' ),
];
}

Expand Down
Loading
Loading