首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使用Node.js客户端库对私有顶点AI端点进行预测?

如何使用Node.js客户端库对私有顶点AI端点进行预测?
EN

Stack Overflow用户
提问于 2022-03-14 13:05:35
回答 1查看 877关注 0票数 1

在发布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}来指定资源名来发出请求,但是这会导致以下错误:

代码语言:javascript
运行
复制
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: {} }
}

我的代码如下所示:

代码语言:javascript
运行
复制
(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);
    })();

有可能提出这样的要求吗?

EN

回答 1

Stack Overflow用户

发布于 2022-09-13 18:24:21

我必须使用以下方法初始化客户端,以便使它按照文档的方式运行。

代码语言:javascript
运行
复制
const client = new PredictionServiceClient({
apiEndpoint: 'us-central1-aiplatform.googleapis.com'

});

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71468270

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档