Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] The expected type comes from property 'pineconeIndex' which is declared here on type 'PineconeStoreParams' #309

Open
kirandash opened this issue Oct 30, 2024 · 7 comments
Labels
bug Something isn't working status:on-roadmap This has been picked up by the team and is on our roadmap

Comments

@kirandash
Copy link

pineconeIndex type error. The issue does not occur with v3.0.3

Error information

Type 'import("/Users/kirandash/workspace/bgwebagency/ai-web-apps/node_modules/@pinecone-database/pinecone/dist/data/index").Index<import("/Users/kirandash/workspace/bgwebagency/ai-web-apps/node_modules/@pinecone-database/pinecone/dist/data/vectors/types").RecordMetadata>' is not assignable to type 'import("/Users/kirandash/workspace/bgwebagency/ai-web-apps/node_modules/@langchain/pinecone/node_modules/@pinecone-database/pinecone/dist/data/index").Index<import("/Users/kirandash/workspace/bgwebagency/ai-web-apps/node_modules/@langchain/pinecone/node_modules/@pinecone-database/pinecone/dist/data/types").RecordMet...'.
  Types have separate declarations of a private property 'config'.

Steps to reproduce the issue locally

  • install the following packages
    "@langchain/community": "^0.3.6",
    "@langchain/openai": "^0.3.11",
    "@langchain/pinecone": "^0.1.1",
    "@langchain/redis": "^0.1.0",
    "@pinecone-database/pinecone": "^4.0.0",

image

My code:

    const vectorStore = await PineconeStore.fromExistingIndex(embeddings, {
      pineconeIndex,
      maxConcurrency: 5,
    });
@kirandash kirandash added the bug Something isn't working label Oct 30, 2024
@github-actions github-actions bot added the status:needs-triage An issue that needs to be triaged by the Pinecone team label Oct 30, 2024
@aulorbe
Copy link
Collaborator

aulorbe commented Oct 31, 2024

Hey @kirandash , could you share your fromExistingIndex function and how you're instantiating PineconeStore as well, please? Thank you!

Without having investigated this issue quite yet, there is a high likelihood this issue stems from Langchain's Pinecone integration, rather than the Pinecone native TS client.

@kirandash
Copy link
Author

kirandash commented Oct 31, 2024

Hey @aulorbe,

Certainly! Here’s how I’m using the fromExistingIndex function and instantiating PineconeStore:

// src/app/api/document-query/route.ts

import { pineconeIndex } from "@/lib/pinecone";
import { OpenAI, OpenAIEmbeddings } from "@langchain/openai";
import { PineconeStore } from "@langchain/pinecone";
import { VectorDBQAChain } from "langchain/chains";
import { NextResponse } from "next/server";

export async function POST(req: Request) {
  const { prompt } = await req.json();

  if (!prompt) {
    return NextResponse.json({ error: "Prompt is required" }, { status: 400 });
  }

  try {
    const model = new OpenAI();

    if (!model) {
      throw new Error("Failed to initialize OpenAI model");
    }

    const embeddings = new OpenAIEmbeddings({
      model: "text-embedding-3-small",
    });

    const vectorStore = await PineconeStore.fromExistingIndex(embeddings, {
      pineconeIndex,
      maxConcurrency: 5,
    });

    const chain = VectorDBQAChain.fromLLM(model, vectorStore, {
      k: 1,
      returnSourceDocuments: true,
    });

    const response = await chain.call({
      query: prompt,
    });

    return NextResponse.json({ result: response });
  } catch (error) {
    console.error(error);
    return NextResponse.json({ error: "An error occurred. Please try again" });
  }
}

And here’s the client setup:

// src/lib/pinecone.ts:

import { Pinecone as PineconeClient } from "@pinecone-database/pinecone";

export const pinecone = new PineconeClient();
export const pineconeIndex = pinecone.Index(process.env.PINECONE_INDEX!);

You can check out the full implementation here: https://github.com/kirandash/ai-web-apps/blob/main/src/app/api/document-query/route.ts

@aulorbe
Copy link
Collaborator

aulorbe commented Oct 31, 2024

Ah okay so fromExistingIndex is a Langchain method?

@kirandash
Copy link
Author

Ah okay so fromExistingIndex is a Langchain method?

Yes, that’s correct! fromExistingIndex is indeed a Langchain method. I’ve noticed that the error does not occur when using @pinecone-database/pinecone version ^3.0.3. However, if I update to the latest release (4.0.0 from last week), the error appears, as shown in the previous screenshot.

@aulorbe
Copy link
Collaborator

aulorbe commented Oct 31, 2024

Ahhh okay, thanks for confirming! It is likely that they just haven't updated their integration since our latest major release (4.0.0), but I will confirm shortly!

@kirandash
Copy link
Author

Ahhh okay, thanks for confirming! It is likely that they just haven't updated their integration since our latest major release (4.0.0), but I will confirm shortly!

Thanks for looking into this! That makes sense. It’s likely an integration update issue with the latest release. I'll stick with version ^3.0.3 for now, but please keep me posted on any updates or fixes. Appreciate the help! 😊🙏

@aulorbe
Copy link
Collaborator

aulorbe commented Oct 31, 2024

Absolutely, will do! Thanks for bearing with both us and Langchain while we get this sorted :)

@anawishnoff anawishnoff added status:on-roadmap This has been picked up by the team and is on our roadmap and removed status:needs-triage An issue that needs to be triaged by the Pinecone team labels Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status:on-roadmap This has been picked up by the team and is on our roadmap
Projects
None yet
Development

No branches or pull requests

3 participants