From 2824f364017ed32ff092c93023ddd473057a7b83 Mon Sep 17 00:00:00 2001 From: Feynman Liang Date: Tue, 24 Jan 2023 07:02:57 -0800 Subject: [PATCH] Add namespace to Pinecone.from_index (#716) Resolves https://github.com/hwchase17/langchain/issues/718 --- langchain/vectorstores/pinecone.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/langchain/vectorstores/pinecone.py b/langchain/vectorstores/pinecone.py index 7810aef8186..514003cb2e8 100644 --- a/langchain/vectorstores/pinecone.py +++ b/langchain/vectorstores/pinecone.py @@ -224,7 +224,11 @@ class Pinecone(VectorStore): @classmethod def from_existing_index( - cls, index_name: str, embedding: Embeddings, text_key: str = "text" + cls, + index_name: str, + embedding: Embeddings, + text_key: str = "text", + namespace: Optional[str] = None, ) -> Pinecone: """Load pinecone vectorstore from index name.""" try: @@ -235,4 +239,6 @@ class Pinecone(VectorStore): "Please install it with `pip install pinecone-client`." ) - return cls(pinecone.Index(index_name), embedding.embed_query, text_key) + return cls( + pinecone.Index(index_name, namespace), embedding.embed_query, text_key + )