在 NodeJS 上预测 AutoML google return INVALID_ARGUMENT

Predict AutoML google return INVALID_ARGUMENT on NodeJS

我的 AutoML 代码有问题。我想 link 它到一个网络项目。我已经使用了 Google tutorial 但它不起作用。我在我的控制台中收到此错误:

payload :  { row:
   { values:
      [ [Object], [Object], [Object], [Object], [Object], [Object] ] } }
{ Error: 3 INVALID_ARGUMENT: Request contains an invalid argument.
    at Object.callErrorFromStatus (E:\Projects\SchoolProject\banking\api\node_modules@grpc\grpc-js\build\src\call.js:30:26)
    at Object.onReceiveStatus (E:\Projects\SchoolProject\banking\api\node_modules@grpc\grpc-js\build\src\client.js:175:52)
    at Object.onReceiveStatus (E:\Projects\SchoolProject\banking\api\node_modules@grpc\grpc-js\build\src\client-interceptors.js:341:141)
    at Object.onReceiveStatus (E:\Projects\SchoolProject\banking\api\node_modules@grpc\grpc-js\build\src\client-interceptors.js:304:181)
    at Http2CallStream.outputStatus (E:\Projects\SchoolProject\banking\api\node_modules@grpc\grpc-js\build\src\call-stream.js:116:74)
    at Http2CallStream.maybeOutputStatus (E:\Projects\SchoolProject\banking\api\node_modules@grpc\grpc-js\build\src\call-stream.js:155:22)
    at Http2CallStream.endCall (E:\Projects\SchoolProject\banking\api\node_modules@grpc\grpc-js\build\src\call-stream.js:141:18)
    at Http2CallStream.handleTrailers (E:\Projects\SchoolProject\banking\api\node_modules@grpc\grpc-js\build\src\call-stream.js:273:14)
    at ClientHttp2Stream.emit (events.js:198:13)
    at emit (internal/http2/core.js:265:8)
  code: 3,
  details: 'Request contains an invalid argument.',
  metadata:
   Metadata {
     internalRepr: Map { 'grpc-server-stats-bin' => [Array] },
     options: {} } }
Error: 3 INVALID_ARGUMENT: Request contains an invalid argument.

我的代码如下所示

由此而来 github repo

我已经创建了 JSON 凭据以将我的 ML 代码用于网站

在这个项目中,我使用 Express (我已经为您删除了代码)

// ========================================
// Config modules
// ========================================
const clientOptions = {
  apiEndpoint: 'eu-automl.googleapis.com'
};
const client = new automl.v1beta1.PredictionServiceClient(clientOptions);
          
// =======================================
// Function for api route
// =======================================
 
const projectId = '*****'; // Project ID from GCP
const computeRegion = 'eu'; // eu (like my bucket)
const modelId = '******'; // modelID from my CGP Table ML
 
const modelFullId = client.modelPath(projectId, computeRegion, modelId);
console.log("modelFullId :", modelFullId)
const sendDataPredict = async (data) => {
  let values = [];
  for (const val in data) {
    values.push({
      [typeof val == 'string' ? 'stringValue' : 'numberValue']: val
    });
  }
 
 
  const payload = {
    row: {
      values: values
    },
   
  };

我试过使用 Postman,但我遇到了同样的错误。 非常感谢您的帮助

尝试使用这个:

const clientOptions = {
  apiEndpoint: 'eu-automl.googleapis.com',
  port: '443'
};