Add namespace to Pinecone.from_index (#716)

Resolves https://github.com/hwchase17/langchain/issues/718
This commit is contained in:
Feynman Liang
2023-01-24 07:02:57 -08:00
committed by GitHub
parent d4f719c34b
commit 2824f36401

View File

@@ -224,7 +224,11 @@ class Pinecone(VectorStore):
@classmethod @classmethod
def from_existing_index( 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: ) -> Pinecone:
"""Load pinecone vectorstore from index name.""" """Load pinecone vectorstore from index name."""
try: try:
@@ -235,4 +239,6 @@ class Pinecone(VectorStore):
"Please install it with `pip install pinecone-client`." "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
)