File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ title: 碎碎念
6
6
7
7
“碎碎念”是本站发布日常随笔的栏目,内容包括项目进展、小点子、有趣的讨论等。
8
8
9
+ - 2024-09-28: [ 凹语言支持Chrome内置AI] ( st0054.md )
9
10
- 2024-09-25: [ 凹语言开发WebAssembly应用3分钟入门] ( st0053.md )
10
11
- 2024-09-22: [ 凹语言再次点亮 Arduino nano 33] ( st0052.md )
11
12
- 2024-09-21: [ 凹语言执行速度比Go快一倍] ( st0051.md )
Original file line number Diff line number Diff line change
1
+ # 凹语言支持Chrome内置AI
2
+
3
+ - 时间:2024-09-28
4
+ - 撰稿:凹语言开发组
5
+ - 转载请注明原文链接:[ https://wa-lang.org/smalltalk/st0054.html ] ( https://wa-lang.org/smalltalk/st0054.html )
6
+
7
+ ---
8
+
9
+ 凹语言是国内首个面向WebAssembly设计通用编程语言,也是目前被 [ CNCF基金会wasm全景图] ( https://landscape.cncf.io/?item=wasm--languages--wa-lang ) 收录的的唯一一个来自中国的开源编程语言项目。凹语言项目诞生时的一个愿景就是简化现代化WebAssembly网页应用的开发。这里我们将展示如何通过凹语言使用Chrome浏览器最新版本内置的Gemini Nano大语言模型。
10
+
11
+ 先参考 [ Device Model: Chrome AI Gemini Nano] ( https://chrome-ai.edgeone.app/ ) , 确保本地 Chrome AI 正常工作, 确保开发者控制台可成功执行 ` await ai.assistant.create(); ` 程序。
12
+
13
+ 示例代码:
14
+
15
+ ``` wa
16
+ import "ai"
17
+
18
+ func main {
19
+ ai.RequestSession(func(session: ai.Session){
20
+ session.PromptAsync("Who are you?", func(res: string) {
21
+ println(res)
22
+ })
23
+ } , "")
24
+ }
25
+ ``
26
+
27
+ 然后本地命令行环境执行`wa run`, 然后在打开的页面的开发者控制台可以看到以下输出:
28
+
29
+ ```
30
+ I am a large language model, trained by Google.
31
+ ```
32
+
33
+ 最后需要说明的是,Chrome内置AI还是一个是实验性,目前凹语言开发组的`ai`包也是在早期测试阶段。
You can’t perform that action at this time.
0 commit comments