搜索插件、代码仓与 APP 分类

插件详情v0.0.10+1

chrome_ai

支持 Flutter 中的 Chrome AI。此包是 Chrome AI API 的包装器。它提供了一种在 Flutter 中使用 Chrome AI API 的简单方法。

近 30 天下载
28
喜欢数
12
Pub 分数
40

安装插件

flutter pub add chrome_ai

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

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 原文快照,最新内容请访问源码仓库。

pub package GitHub

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.

1. Enable AI in Chrome

Chrome built-in AI is a preview feature, you need to use chrome version 127 or greater, now in dev or canary channel, may release on stable chanel at Jul 17, 2024.

After then, you should turn on these flags:

  • [chrome://flags/#prompt-api-for-gemini-nano](chrome://flags/#prompt-api-for-gemini-nano): Enabled
  • [chrome://flags/#optimization-guide-on-device-model](chrome://flags/#optimization-guide-on-device-model): Enabled BypassPrefRequirement
  • [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 = await ChromeAI.canCreateTextSession();
if(availability == AIModelAvailability.no){
    // can not create text session
}else if(availability == AIModelAvailability.afterDownload) {
    // need to download model
}else if(availability == AIModelAvailability.readily){
    // model is ready
}
Generate Text
import 'package:chrome_ai/chrome_ai.dart';

final session = await ChromeAI.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 = await ChromeAI.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.

所属分类

依赖

依赖清单 1 项

  • js^0.7.1

源码仓库

使用此插件的项目

暂无相关数据。