简体   繁体   中英

(Google AutoML) Error: 3 INVALID_ARGUMENT: Unsupported payload type `row`

I'm trying to port a Python function, to javascript, that runs a prediction model created on Google Cloud.

Everything works perfectly, until calling the .predict() method as it always throws an Unsupported payload type row error message.

The format of the payload is quite simple:

const data = [ { key1: value1, key2: value2, key3: value3 ... } ];

In case it helps, here's a portion of the code:

const {PredictionServiceClient} = require('@google-cloud/automl').v1beta1;

const ai = new PredictionServiceClient({
    projectId: projectId
});
const payload = {
    row: {
        values: data
    }
};
const request = {
    name: ai.modelPath(projectId, computeRegion, modelId),
    payload: payload,
    params: {feature_importance: true}
};
const [result] = await ai.predict(request);

And here's the original Python code from which the js version is based on:

from google.cloud import aiplatform

aiplatform.init(project=PROJECT_ID, location=compute_region)
endpoint = aiplatform.Endpoint(ENDPOINT_ID)
response = endpoint.predict(instances=data)

Please let me know if I should provide any additional information. Any hints will be greatly appreciated!

Its good to know that you were able to solve your issue. I'm leaving this answer of the current aiplatform libraries in use as November 2021 for the community.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM