LlabeL
Convex Community12mo ago
3 replies
Llabe

gemini

import { GoogleGenerativeAI } from '@google/generative-ai';
import { action } from './_generated/server';

export const generateResponse = action({
args: {},
handler: async (ctx, args) => {
const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY as string);
const model = genAI.getGenerativeModel({ model: 'gemini-1.5-flash-8b' });

const chat = model.startChat({
history: [
{
role: 'user',
parts: [{ text: 'My name is Pedro' }],
},
],
});
const result = await chat.sendMessage(
'You have access to the history of messages from this chat session right?'
);
console.log(result.response.text());
return result.response.text();
},
});

Is omething like this correct? Or then will I have issues when deploying?
Was this page helpful?