我的AutoML代码有问题。我想把它链接到一个网络项目。我使用过Google教程,但它不起作用。我在我的控制台中收到了这个错误:
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.我的代码如下所示
它来自于这个https://github.com/googleapis/nodejs-automl/blob/master/samples/tables/predict.v1beta1.js
我创建了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
},
};我试过邮递员,但我也犯了同样的错误。非常感谢你的帮助
发布于 2020-11-05 13:19:00
试着使用这个:
const clientOptions = {
apiEndpoint: 'eu-automl.googleapis.com',
port: '443'
};https://stackoverflow.com/questions/62695572
复制相似问题