Use Vertex AI to call Gemini 1.5 Pro latest model to perform translation
gcloud auth application-default login
- Copy .env.example to .env
- Update GOOGLE_PROJECT_ID to Google Cloud Project
- Update GOOGLE_LOCATION to Google Cloud Project
- Update GOOGLE_MODEL to a model found in Vertex AI Model Garden
Add texts to sample array
const samples = [
'Good morning',
'Hello, how are you today?',
'How much does 3 apples and 4 oranges cost?'
]
and the results are
[
{
"en": "Good morning",
"es": "Buenos Dias"
},
{
"en": "Hello, how are you today?",
"es": "Hola, ¿cómo estás hoy?"
},
{
"en": "How much does 3 apples and 4 oranges cost?",
"es": "¿Cuánto cuestan tres manzanas, cinco piñas y cuatro naranjas?"
}
]
Change the TARGET environment variable in the "start script" of package.json
"scripts": {
"start": "TARGET=<target language code> node -r ts-node/register --env-file=.env index.ts"
}
pnpm start
gcloud auth application-default revoke