在发布https://cloud.google.com/vertex-ai/docs/predictions/using-private-endpoints#sending-prediction-to-private-endpoint时,这方面的文档有点模糊,他们只提到了如何使用curl。
如果可能的话,我想使用node.js客户机库,但我只找到了一些不使用私有端点的示例,即:https://github.com/googleapis/nodejs-ai-platform/blob/main/samples/predict-custom-trained-model.js。
我已经阅读了从PredictionServiceClient
导入的@google-cloud/aiplatform
的类型定义,没有找到插入我的私有端点的方法。我已经尝试通过简单地通过执行const endpoint = projects/${project}/locations/${location}/endpoints/${endpointId}
来指定资源名来发出请求,但是这会导致以下错误:
Error: 13 INTERNAL: Received RST_STREAM with code 0
at Object.callErrorFromStatus (/home/vitor/vertexai/node_modules/@grpc/grpc-js/src/call.ts:81:24)
at Object.onReceiveStatus (/home/vitor/vertexai/node_modules/@grpc/grpc-js/src/client.ts:343:36)
at Object.onReceiveStatus (/home/vitor/vertexai/node_modules/@grpc/grpc-js/src/client-interceptors.ts:462:34)
at Object.onReceiveStatus (/home/vitor/vertexai/node_modules/@grpc/grpc-js/src/client-interceptors.ts:424:48)
at /home/vitor/vertexai/node_modules/@grpc/grpc-js/src/call-stream.ts:323:24
at processTicksAndRejections (node:internal/process/task_queues:78:11) {
code: 13,
details: 'Received RST_STREAM with code 0',
metadata: Metadata { internalRepr: Map(0) {}, options: {} }
}
我的代码如下所示:
(async () => {
const client = new v1beta1.PredictionServiceClient();
const location = "****";
const project = "****";
const endpointId = "****"
const endpoint = `projects/${project}/locations/${location}/endpoints/${endpointId}`;
const parameters = {
structValue: {
fields: {},
},
};
const toInstance = (obj: any) => (
{
structValue: {
fields: {
****
}
}
});
const instance = toInstance(****);
const instances = [instance];
const res = await client.predict({
instances,
endpoint,
parameters
});
console.log(res);
})();
有可能提出这样的要求吗?
发布于 2022-09-13 18:24:21
我必须使用以下方法初始化客户端,以便使它按照文档的方式运行。
const client = new PredictionServiceClient({
apiEndpoint: 'us-central1-aiplatform.googleapis.com'
});
https://stackoverflow.com/questions/71468270
复制相似问题