上次看到 @Livid 分享的 python 版本的 https://www.fshex.com/t/1100770
今天上去看了下也有 js 版本了
github: https://github.com/google-gemini/generative-ai-js
const { getGenerativeModel } = require('@google-gemini/generative-ai-js')
async function generateText() {
const model = await getGenerativeModel({ model: 'gemini-pro' })
const request = { prompt: '请写一个 js 版本的 websocket 服务' }
const response = await model.generateContent(request)
// print response text
console.log(response.text)
}
generateText()
|