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?
3 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
Have you tried? You may need
'use node'
at the top.So far it works. I havent tried in production