While deploying my project, i am facing issue regrading vectorStore and PineconeIndex

I while deploying my project, i am this getting error:

Type 'VectorOperationsApi' is missing the following properties from type 'Index<RecordMetadata>': config, target, deleteAll, deleteMany, and 6 more.ts(2740) pinecone.d.ts(8, 5): The expected type comes from property 'pineconeIndex' which is declared here on type 'PineconeLibArgs' (property) PineconeLibArgs.pineconeIndex: Index<RecordMetadata>

I am unable to understand what it is all about, neither I find solution on internet.

`public async vectorSearch(
recentChatHistory: string,
companionFileName: string
) {
const pineconeClient = this.vectorDBClient;

const pineconeIndex = pineconeClient.Index(
  process.env.PINECONE_INDEX! || ""
);

const vectorStore = await PineconeStore.fromExistingIndex(
  new OpenAIEmbeddings({ openAIApiKey: process.env.OPENAI_API_KEY }),
  { pineconeIndex }
); 

const similarDocs = await vectorStore
  .similaritySearch(recentChatHistory, 3, { fileName: companionFileName })
  .catch((err) => {
    console.log("WARNING: failed to get vector search results.", err);
  });
return similarDocs;

}`

this is the part of code i am working with
type or paste code here


if you want complete code follow this link of github: [Git hub Project link](https://github.com/opcxder/ai-companion/blob/main/lib/memory.ts).

If anyone facing same issue, and solved it kindly help me out

This is related to Langchain and not the Pinecone Typescript interface. Currently, the easiest workaround is to pass in an init’d pinecone client connection. Working with the code I got something like this.

// You currently define this.vectorDBClient = new PineconeClient();
// You should init the connection first
 await vectorDBClient.init({
   environment: process.env.PINECONE_ENVIRONMENT,
   apiKey: process.env.PINECONE_API_KEY
 });

const pineconeIndex = vectorDBClient.Index(
  process.env.PINECONE_INDEX_NAME as string
);

// Now the rest of your code as normal
const vectorStore = await PineconeStore.fromExistingIndex(
  new OpenAIEmbeddings({ openAIApiKey: process.env.OPENAI_API_KEY }),
  { pineconeIndex }
); 

const similarDocs = await vectorStore
  .similaritySearch(recentChatHistory, 3, { fileName: companionFileName })
  .catch((err) => {
    console.log("WARNING: failed to get vector search results.", err);
  });
return similarDocs;
1 Like

Thanks for seeing and solving my issue, as you can see i have already init vectorDBClient, So can you tell me if have i correctly init or not, or there is another syntax or logical error.

export class MemoryManager {
  private static instance: MemoryManager;
  private history: Redis;
  private vectorDBClient: PineconeClient;

  public constructor() {
    this.history = Redis.fromEnv();
    this.vectorDBClient = new PineconeClient();
  }

  public async init() {
    if (this.vectorDBClient instanceof PineconeClient) {
      await this.vectorDBClient.init({
        apiKey: process.env.PINECONE_API_KEY!,
        environment: process.env.PINECONE_ENVIRONMENT!,
      });
    }
  }

  public async vectorSearch(
    recentChatHistory: string,
    companionFileName: string
  ) {
    const pineconeClient = <PineconeClient>this.vectorDBClient;
    
    const pineconeIndex = pineconeClient.Index(
      process.env.PINECONE_INDEX! || ""
    );

    const vectorStore = await PineconeStore.fromExistingIndex(
      new OpenAIEmbeddings({ openAIApiKey: process.env.OPENAI_API_KEY }),
      { pineconeIndex }
    ); 

    const similarDocs = await vectorStore
      .similaritySearch(recentChatHistory, 3, { fileName: companionFileName })
      .catch((err) => {
        console.log("WARNING: failed to get vector search results.", err);
      });
    return similarDocs;
  }

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.