langchain-ai / langchainjs

🦜🔗 Build context-aware reasoning applications 🦜🔗
https://js.langchain.com/docs/
MIT License
12.42k stars 2.1k forks source link

PineconeClient is deprecated. #2643

Closed toypilot closed 3 months ago

toypilot commented 1 year ago

Hello. Pinecone node libaray is upgrade to v1 There is a problem with that.

export { Pinecone } from './pinecone';
export { Index } from './data';
export * as Errors from './errors';
export type { CollectionDescription, CollectionList, CollectionName, ConfigureIndexOptions, CreateCollectionOptions, CreateIndexOptions, DeleteCollectionOptions, DeleteIndexOptions, DescribeCollectionOptions, DescribeIndexOptions, IndexDescription, IndexList, IndexName, PartialIndexDescription, PartialCollectionDescription, } from './control';
export type { DeleteManyByFilterOptions, DeleteManyByRecordIdOptions, DeleteManyOptions, DeleteOneOptions, DescribeIndexStatsOptions, FetchOptions, FetchResponse, IndexStatsDescription, IndexStatsNamespaceSummary, PineconeConfiguration, PineconeRecord, UpdateOptions, QueryByRecordId, QueryByVectorValues, QueryOptions, QueryResponse, QueryShared, RecordId, RecordMetadata, RecordMetadataValue, RecordSparseValues, RecordValues, ScoredPineconeRecord, } from './data';
export { PineconeClient } from './v0';
export { utils } from './v0/utils';
export { CreateCollectionRequest, CreateRequest, DeleteRequest, IndexMeta, PatchRequest, QueryRequest, QueryVector, ScoredVector, UpdateRequest, UpsertRequest, Vector, } from './pinecone-generated-ts-fetch';

As you can see, PineconeClient and utils are deprecated. As a result, PineconeStore can not be created. I am using these versions. "langchain": "^0.0.150" "@pinecone-database/pinecone": "^1.0.1"

Please, fix this error,

dosubot[bot] commented 1 year ago

🤖

Hello,

Thank you for bringing this to our attention. The issue you're facing is due to the deprecation of PineconeClient and utils in the Pinecone node library version 1. The PineconeStore class in the langchain version 0.0.150 is still using these deprecated components.

To resolve this issue, you need to replace the deprecated PineconeClient with the new Pinecone class and its index method. The index method is used to create an instance of the VectorOperationsApi type, which is used in the PineconeStore class.

Here's how you can modify the PineconeStore class to use the new Pinecone class:

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

// ...

type VectorOperationsApi = ReturnType<
  Pinecone["index"]
>;

// ...

export class PineconeStore extends VectorStore {
  // ...

  constructor(embeddings: Embeddings, args: PineconeLibArgs) {
    super(embeddings, args);

    // ...

    this.pineconeIndex = new Pinecone().index(args.pineconeIndexName);
    // ...
  }

  // ...
}

In the above code, I've replaced the PineconeClient with the Pinecone class and used its index method to create an instance of the VectorOperationsApi type. I've also added a new argument pineconeIndexName to the PineconeLibArgs type and the PineconeStore constructor, which is used to specify the name of the Pinecone index.

Please note that you need to replace all occurrences of PineconeClient with Pinecone and its index method in the PineconeStore class. Also, you need to update the PineconeLibArgs type and the PineconeStore constructor to accept the pineconeIndexName argument.

I hope this helps. If you have any other questions or run into any issues, please let me know.

Best, Dosu

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

LukasGaebler commented 1 year ago

Any updates on this? Does someone know if somebody is looking at this?

bkamapantula commented 1 year ago

Hi @LukasGaebler, you can use and see if this resolves the issue.

import { Pinecone } from "@pinecone-database/pinecone";
const client = new Pinecone({
  apiKey: process.env.PINECONE_API_KEY!,
  environment: process.env.PINECONE_ENVIRONMENT!,
});

Please update langchain and pinecone dependencies to the latest versions.

srikanthcanny commented 1 year ago

Isn't this fixed in #2648?

RodrigoLegendre commented 11 months ago

Not fixed as of 2023-10-15.

I still get:

TS2740: Type  Index<RecordMetadata>  is missing the following properties from type  VectorOperationsApi :  _deleteRaw, _delete, delete1Raw, delete1 , and  16  more.
pinecone.d.ts(8, 5): The expected type comes from property  pineconeIndex  which is declared here on type  PineconeLibArgs 

on the pineconeIndex: index, on:

await PineconeStore.fromDocuments(docs, embeddings, {
    pineconeIndex: index,
    namespace: PINECONE_NAME_SPACE,
    textKey: 'text',
});

where: const index = client.Index(PINECONE_INDEX_NAME); and client: Pinecone (not PineconeClient)

I have no idea how to fix it.

RodrigoLegendre commented 11 months ago

The Typescript definitions for VectorOperationsApi are still using the deprecated PineconeClient as ReturnType for index()?

pinecone.d.ts:

type VectorOperationsApi = ReturnType<import("@pinecone-database/pinecone").PineconeClient["Index"]>;
export interface PineconeLibArgs extends AsyncCallerParams {
    pineconeIndex: VectorOperationsApi;
    textKey?: string;
    namespace?: string;
    filter?: PineconeMetadata;
}
aditya0shah commented 9 months ago

Is there any updates on this? Or rather updated ways to get around this error? PineconeStore.fromTexts() also has the same issue of not being able to pass index (const index = pinecone.Index("index-name"))to pineconeIndex inside of dbConfig.

richard523 commented 6 months ago
await PineconeStore.fromDocuments(docs, embeddings, {
            pineconeIndex: index,
            namespace: namespace
            // maxConcurrency: 5, // Maximum number of batch requests to allow at once. Each batch is 1000 vectors.
          });
error PineconeNotFoundError: A call to https://api.pinecone.io/indexes/pdf-chat-serverless returned HTTP status 404.

I'm getting different error though.