Hi team,
I´ve created a very simple node program that connects to vertex ai, sends an image using the model:
gemini-1.5-pro-preview-0409
and expects a response with the text found on that image.
There must a be problem with the env requirements of the SDK because works perfectly in localhost but not in a node:20.14.0 image. Here the code:
const { VertexAI } = require('@google-cloud/vertexai');
async function geminiConnectorImage2Text(base64Img) {
try {
// Inicialización de Vertex AI con detalles del proyecto y ubicación
const vertex_ai = new VertexAI({
project: 'authtlc',
location: 'us-central1'
});
const model = 'gemini-1.5-pro-preview-0409';
// Instanciación del modelo generativo
const generativeModel = vertex_ai.preview.getGenerativeModel({
model: model,
generationConfig: {
maxOutputTokens: 8192,
temperature: 1,
topP: 0.95,
},
safetySettings: [
{ category: 'HARM_CATEGORY_HATE_SPEECH', threshold: 'BLOCK_MEDIUM_AND_ABOVE' },
{ category: 'HARM_CATEGORY_DANGEROUS_CONTENT', threshold: 'BLOCK_MEDIUM_AND_ABOVE' },
{ category: 'HARM_CATEGORY_SEXUALLY_EXPLICIT', threshold: 'BLOCK_MEDIUM_AND_ABOVE' },
{ category: 'HARM_CATEGORY_HARASSMENT', threshold: 'BLOCK_MEDIUM_AND_ABOVE' }
]
});
// Creación de la imagen inline
const image1 = {
inlineData: {
mimeType: 'image/jpeg',
data: base64Img
}
};
// Generación de contenido
const req = {
contents: [
{ role: 'user', parts: [image1, { text: `escribe todo lo que leas en la siguiente imagen` }] }
]
};
console.log("generating response")
const streamingResp = await generativeModel.generateContent(req);
once the generateContent is invoked I see no response at all from the library...
I´ve logged in into Gloud and set my project quota...
Any ideas on what to do here, I feel so stucked.
Thanks in advance,
Mendiu
I've been able to make it work using npn run dev, the problem seems to be when building the app... I am still looking for a solution...
Any ideas will be appreciated!
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |