
要在 chrome 中使用实验性 ai api,请按照以下步骤操作:
硬件要求
尚不支持:
- chrome操作系统
- chrome ios
- chrome 安卓
软件要求
- 安装 chrome canary
- 通过修改以下标志来激活人工智能和模型:
- 转到 chrome://flags/#optimization-guide-on-device-model 并选择“启用 bypassperfrequirement”
- 前往 chrome://flags/#prompt-api-for-gemini-nano 并选择“启用”
- 重新启动 chrome
- 通过在控制台中运行以下命令来验证安装: (等待 ai.assistant.capability())。可用。 它应该“立即”返回。
如果失败,请尝试以下操作:
- 运行await ai.assistant.create()来尝试强制chrome激活api(尽管它可能不起作用)。
- 前往 chrome://components 检查“设备型号优化指南”组件的版本是否等于或大于 2024.5.21.1031。如果您没有版本,请点击“检查更新”并重试。
注意:有时模型安装可能需要一段时间。如有必要,请耐心等待并重复该过程。
模型激活
要激活模型,请在 chrome 中启用以下标志:
- chrome://flags/#prompt-api-for-gemini-nano
- chrome://flags/#summarization-api-for-gemini-nano
- chrome://flags/#rewriter-api-for-gemini-nano
- chrome://flags/#writer-api-for-gemini-nano
- chrome://flags/#语言-检测-api
可用功能
提示api
这是最简单的模型,用于一般任务。当您向它发送提示时,它会尝试返回响应。这是一个基本示例:
免费 盛世企业网站管理系统(SnSee)系统完全免费使用,无任何功能模块使用限制,在使用过程中如遇到相关问题可以去官方论坛参与讨论。开源 系统Web代码完全开源,在您使用过程中可以根据自已实际情况加以调整或修改,完全可以满足您的需求。强大且灵活 独创的多语言功能,可以直接在后台自由设定语言版本,其语言版本不限数量,可根据自已需要进行任意设置;系统各模块可在后台自由设置及开启;强大且适用的后台管理支
const session = await ai.assistant.create();
const result = await session.prompt("explain what javascript is");
您还可以使用systemprompt传递附加指令:
const session = await ai.assistant.create({
systemprompt: "you are an expert in javascript, providing helpful code best practices."
});
语言检测
该api检测文本的语言,支持100多种语言及其变体。
示例:
const detector = await translation.createdetector();
const results = await detector.detect("bonjour le monde");
for (const result of results) {
console.log(result.detectedlanguage, result.confidence);
}
作家和重写者
writer api:创建新内容。
示例:向银行写一份申请草稿。
const writer = await ai.writer.create();
const result = await writer.write("write a email asking for feedback");
重写器 api: 改进或重组现有文本。
const rewriter = await ai.rewriter.create();
const result = await rewriter.rewrite("La inteligencia artificial es...", { context: "Use simple words." });
所有这些 api 都处于实验阶段,因此发现错误或不一致是正常的。欢迎所有反馈。如果您有兴趣了解这些更改,可以填写此表格来访问文档并接收更新。









