Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 节点Google Cloud AutoML PredictionService客户端问题_Node.js_Google Cloud Platform_Google Cloud Automl_Automl - Fatal编程技术网

Node.js 节点Google Cloud AutoML PredictionService客户端问题

Node.js 节点Google Cloud AutoML PredictionService客户端问题,node.js,google-cloud-platform,google-cloud-automl,automl,Node.js,Google Cloud Platform,Google Cloud Automl,Automl,我试图使用google cloud automl API使用其分类服务,但返回以下错误: { Error: 3 INVALID_ARGUMENT: Request contains an invalid argument. at Object.callErrorFromStatus (/Users/lucasreis/Documents/GitHub/base-cleaning/node_modules/@grpc/grpc-js/src/call.ts:81:24) at Ob

我试图使用google cloud automl API使用其分类服务,但返回以下错误:

{ Error: 3 INVALID_ARGUMENT: Request contains an invalid argument.
    at Object.callErrorFromStatus (/Users/lucasreis/Documents/GitHub/base-cleaning/node_modules/@grpc/grpc-js/src/call.ts:81:24)
    at Object.onReceiveStatus (/Users/lucasreis/Documents/GitHub/base-cleaning/node_modules/@grpc/grpc-js/src/client.ts:324:36)
    at Object.onReceiveStatus (/Users/lucasreis/Documents/GitHub/base-cleaning/node_modules/@grpc/grpc-js/src/client-interceptors.ts:439:34)
    at Object.onReceiveStatus (/Users/lucasreis/Documents/GitHub/base-cleaning/node_modules/@grpc/grpc-js/src/client-interceptors.ts:402:48)
    at Http2CallStream.outputStatus (/Users/lucasreis/Documents/GitHub/base-cleaning/node_modules/@grpc/grpc-js/src/call-stream.ts:228:22)
    at Http2CallStream.maybeOutputStatus (/Users/lucasreis/Documents/GitHub/base-cleaning/node_modules/@grpc/grpc-js/src/call-stream.ts:278:14)
    at Http2CallStream.endCall (/Users/lucasreis/Documents/GitHub/base-cleaning/node_modules/@grpc/grpc-js/src/call-stream.ts:262:12)
    at Http2CallStream.handleTrailers (/Users/lucasreis/Documents/GitHub/base-cleaning/node_modules/@grpc/grpc-js/src/call-stream.ts:392:10)
    at ClientHttp2Stream.emit (events.js:182:13)
    at ClientHttp2Stream.EventEmitter.emit (domain.js:442:20)
    at emit (internal/http2/core.js:237:8)
    at process._tickCallback (internal/process/next_tick.js:63:19)
  code: 3,
  details: 'Request contains an invalid argument.',
  metadata:
   Metadata {
     internalRepr: Map { 'grpc-server-stats-bin' => [Array] },
     options: {} } }
我的代码与文档完全相同:


function main(
  projectId = 'YOUR_PROJECT_ID',
  location = 'us-central1',
  modelId = 'YOUR_MODEL_ID',
  content = 'text to predict'
) {


  // Imports the Google Cloud AutoML library
  const {PredictionServiceClient} = require('@google-cloud/automl').v1;

  // Instantiates a client
  const client = new PredictionServiceClient();

  async function predict() {
    // Construct request
    const request = {
      name: client.modelPath(projectId, location, modelId),
      payload: {
        textSnippet: {
          content: content,
          mimeType: 'text/plain', // Types: 'test/plain', 'text/html'
        },
      },
    };

    const [response] = await client.predict(request);

    for (const annotationPayload of response.payload) {
      console.log(`Predicted class name: ${annotationPayload.displayName}`);
      console.log(
        `Predicted class score: ${annotationPayload.classification.score}`
      );
    }
  }
我试图查看他们的文档,但没有找到任何答案。奇怪的是,当我使用projet的模型ID作为实体提取时,它工作得非常好


有人能帮我吗?谢谢大家!

如果模型id引用了错误的模型或其他实体,则会出现此错误。我是在错误地使用数据集id(与模型id的形式相同)时得到这个结果的。

您得到了有效的答案吗?