Skip to content

Commit 7163c7d

Browse files
committed
feat: 添加生成GeminiNano的功能
1 parent a5da43e commit 7163c7d

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

docs/src/gemini-nano.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const generateGeminiNano = async () => {
2+
const { defaultTemperature, maxTemperature, defaultTopK, maxTopK } = await LanguageModel.params()
3+
4+
const available = await LanguageModel.availability()
5+
if (available !== 'unavailable') {
6+
const session = await LanguageModel.create()
7+
8+
// Prompt the model and stream the result:
9+
const stream = session.promptStreaming('你好')
10+
for await (const chunk of stream) {
11+
console.log(chunk)
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)