javascript 来自节点'RequiredError'的PineconeClient的错误:调用upsert时,所需参数requestParameters.upsertRequest为null或未定义,'

t1qtbnec  于 2023-05-16  发布在  Java
关注(0)|答案(1)|浏览(204)

当我使用PineconeClient for nodejs将向量upsert到PineCone时出错
代码是

const index = pinecone.Index("imagesindex");
const upsertRequest = {
  vectors: [
    {
      id: "vec1",
      values: [0.1, 0.2, 0.3, 0.4],
      metadata: {
        genre: "drama",
      },
    },
    {
      id: "vec2",
      values: [0.2, 0.3, 0.4, 0.5],
      metadata: {
        genre: "action",
      },
    },
  ],
  namespace: "example-namespace",
};
try {
  const upsertResponse = await index.upsert(upsertRequest);  
} catch (error) {
  console.log(error);
}

index.upsert return“RequiredError:调用upsert时,所需参数requestParameters.upsertRequest为null或未定义”
什么是正确的index.upsert?

wpx232ag

wpx232ag1#

从PineconeClient的GitHub repo中得到:

const upsertRequest: UpsertRequest = {
    vectors,
    namespace,
};
await index.upsert({ upsertRequest });

我认为你应该试试这个:

try {
    const upsertResponse = await index.upsert({ upsertRequest });  
} catch (error) {
    console.log(error);
}

您传入的参数的字段upsertRequest为空。当您应该将upsertRequest作为requestParameters.upsertRequest传递时,您将其作为requestParameters传递

相关问题