You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Langchain项目使用Pinecone向量存储时遇PineconeArgumentError报错排查

问题解决:PineconeArgumentError 参数类型错误

错误原因

你调用 pinecone.Index() 时没有传入具体的Pinecone索引名称,该方法要求必须传入字符串类型的索引名,因此触发了参数类型错误。

解决方案

  1. 在 pinecone.Index() 中补充你在Pinecone控制台创建好的索引名称(字符串格式)
  2. 确保该索引的维度与你使用的OpenAIEmbeddings维度匹配(OpenAI的text-embedding-ada-002对应1536维)

修改后的代码

const pinecone = new Pinecone();

// 替换为你实际的Pinecone索引名称
const pineconeIndex = pinecone.Index("your-pinecone-index-name");

const docs = [
  new Document({
    metadata: { foo: "bar" },
    pageContent: "pinecone is a vector db",
  }),
  new Document({
    metadata: { foo: "bar" },
    pageContent: "the quick brown fox jumped over the lazy dog",
  }),
  new Document({
    metadata: { baz: "qux" },
    pageContent: "lorem ipsum dolor sit amet",
  }),
  new Document({
    metadata: { baz: "qux" },
    pageContent: "pinecones are the woody fruiting body and of a pine tree",
  }),
];

await PineconeStore.fromDocuments(docs, new OpenAIEmbeddings(), {
  pineconeIndex,
  maxConcurrency: 5, // Maximum number of batch requests to allow at once. Each batch is 1000 vectors.
});

内容的提问来源于stack exchange,提问作者Kingsley

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 02:35:19