跳至主要内容

ChromeAI

信息

此功能为实验性功能,可能随时更改。

注意

Google 的内置 AI 早期预览计划目前处于测试阶段。要申请访问权限或查找更多信息,请访问此链接.

ChromeAI 利用 Gemini Nano 在浏览器或worker中直接运行 LLM,无需互联网连接。这允许运行更快速和私密的模型,而无需将数据离开消费者的设备。

入门

获得程序访问权限后,请按照 Google 提供的说明下载模型。

下载完成后,您可以按以下步骤在浏览器中开始使用ChromeAI

import { ChromeAI } from "@langchain/community/experimental/llms/chrome_ai";

const model = new ChromeAI({
temperature: 0.5, // Optional, defaults to 0.5
topK: 40, // Optional, defaults to 40
});

const response = await model.invoke("Write me a short poem please");

/*
In the realm where moonlight weaves its hue,
Where dreams and secrets gently intertwine,
There's a place of tranquility and grace,
Where whispers of the night find their place.

Beneath the canopy of starlit skies,
Where dreams take flight and worries cease,
A haven of tranquility, pure and true,
Where the heart finds solace, finding dew.

In this realm where dreams find their release,
Where the soul finds peace, at every peace,
Let us wander, lost in its embrace,
Finding solace in this tranquil space.
*/

流式传输

ChromeAI 还支持流式传输输出

import { ChromeAI } from "@langchain/community/experimental/llms/chrome_ai";

const model = new ChromeAI({
temperature: 0.5, // Optional, defaults to 0.5
topK: 40, // Optional, defaults to 40
});

for await (const chunk of await model.stream("How are you?")) {
console.log(chunk);
}

/*
As
an
AI
language
model
,
I
don
'
t
have
personal
experiences
or
the
ability
to
experience
emotions
.
Therefore
,
I
cannot
directly
answer
the
question
"
How
are
you
?".



May
I
suggest
answering
something
else
?
*/

此页面对您有帮助吗?


您还可以留下详细的反馈 在 GitHub 上.