Daisuke Takamizawa
Daisuke Takamizawa

Reputation: 65

aiplafrom fails to create a client with Vite + Vue + TS

I'm trying Gemini Pro on Vite + Vue + TS, but I get an error when try to create an instance of PredictionServiceClient. The error is Uncaught TypeError: Class extends value undefined is not a constructor or null, I think this error occurs when there are circular references. But I can't find why it's occurred.

Does anyone have any ideas to solve this?

This is part of my code.

import * as aiplatform from '@google-cloud/aiplatform';

const { PredictionServiceClient } = aiplatform.v1beta1;
const { helpers } = aiplatform;
const clientOptions = {
  credentials: {
    client_email: import.meta.env.VUE_APP_CLIENT_EMAIL,
    private_key: import.meta.env.VUE_APP_PRIVATE_KEY,
  },
  apiEndpoint: import.meta.env.VUE_APP_API_ENDPOINT,
};

const client = new PredictionServiceClient(clientOptions);

This is an error message.

Uncaught TypeError: Class extends value undefined is not a constructor or null
    at node_modules/agent-base/dist/index.js (index.ts:29:42)
    at __require2 (chunk-TDUMLE5V.js?v=4e2d0ad9:10:50)
    at node_modules/https-proxy-agent/dist/index.js (index.ts:7:1)
    at __require2 (chunk-TDUMLE5V.js?v=4e2d0ad9:10:50)
    at node_modules/gaxios/build/src/gaxios.js (gaxios.ts:33:1)
    at __require2 (chunk-TDUMLE5V.js?v=4e2d0ad9:10:50)
    at node_modules/gaxios/build/src/index.js (index.ts:15:1)
    at __require2 (chunk-TDUMLE5V.js?v=4e2d0ad9:10:50)
    at node_modules/gcp-metadata/build/src/index.js (index.ts:8:1)
    at __require2 (chunk-TDUMLE5V.js?v=4e2d0ad9:10:50)

UPDATES

I can't solve this error. But my purpose is using Gemini Pro, so I decided to move to Gemini API and it's working well with the same environment.

This is Google's Quickstarts. If you are interested, please click it.

https://cloud.google.com/vertex-ai/docs/generative-ai/start/quickstarts/quickstart-multimodal

Upvotes: 0

Views: 108

Answers (1)

Daisuke Takamizawa
Daisuke Takamizawa

Reputation: 65

aiplatform requires Service Account and it can't be used on a browser. So it should be moved to Server-side.

Upvotes: 1

Related Questions