chrome_ai 包是 Chrome AI API 的 Flutter 包裝,使開發者能夠將其 Chrome AI 功能整合到 Flutter 應用中。它簡化了對自然語言處理和生成式回應等 AI 功能的存取。該包專為在 Flutter 項目中無縫使用而設計,將複雜的 API 互動抽象為簡單的方法。該包非常適合希望利用 AI 驅動的聊天、內容產生或智慧使用者協助功能的應用。它支援未來的平台擴展,儘管目前的平台支援尚未明確。
適用情境
AI 驅動的聊天介面
應用中的內容產生
智慧助理整合
即時語言處理
增強的使用者與AI的互動
自動回應系統
主要特色
Chrome AI 的簡單 API 包裝器
無縫的 Flutter 集成
支援產生式AI任務
乾淨、易用的方法
面向未來,支援平台擴展
輕量且專注
適合對象
開發 AI 增強型 Flutter 應用的開發者
整合Chrome AI功能的團隊
需要即時文本生成的應用程式
原型設計人工智慧驅動的使用者體驗
旨在最小化設置開銷的項目
使用建議
未列出特定平台的支援
依賴外部 Chrome AI API 的可用性
有限的文件暗示
需要互聯網連接以進行AI呼叫
取決於出版商的維護
不適用於離線AI功能
原始 README
以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。
ChromeAI
Recently, Chrome has added window.ai — a Gemini Nano AI model right inside your browser. This means that web developers can instantly and unlimitedly use on-device AI without any configuration.
I believe this will truly transform web applications. The use-cases are endless: smart auto-completion, error correction and validation, natural language filtering, auto-filling forms, UI suggestions, first-pass summarization, and search.
Accordingly, I have developed a library to enable this feature in Flutter. With this library, you can easily utilize the feature in Flutter web as well.
Installation
you can watch this video to see how to enable AI in Chrome and run this library.
[chrome://components/](chrome://components/): Click Optimization Guide On Device Model to download the model.
2. Add library
flutter pub add chrome_ai
3. Run your project
1. Open terminal and run web-server
flutter run -d web-server
2. Open Chrome dev or canary, and open your project in http://localhost:port
Usage
Check Availability of Chrome AI
import'package:chrome_ai/chrome_ai.dart';
final availability = awaitChromeAI.canCreateTextSession();
if(availability == AIModelAvailability.no){
// can not create text session
}elseif(availability == AIModelAvailability.afterDownload) {
// need to download model
}elseif(availability == AIModelAvailability.readily){
// model is ready
}
Generate Text
import'package:chrome_ai/chrome_ai.dart';
final session = awaitChromeAI.createTextSession();
var result = await session.prompt("why is the sky blue?");
print(result);
Generate Streaming Text
import'package:chrome_ai/chrome_ai.dart';
final session = awaitChromeAI.createTextSession();
final stream = session.promptStreaming("why is the sky blue?");
stream.listen((result) {
print(result);
}).onError((e, stackTrace) {
print(e.toString());
});
Need Help!
This project is very new. If you have any questions, please open an issue. Contributions are very welcome.