diff --git a/pyproject.toml b/pyproject.toml index 79c09ae2..9f333aac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,8 @@ packages = [{include = "canopy", from = "src"}, [tool.poetry.dependencies] python = ">=3.9,<3.13" -pinecone-client = "^3.0.0" +pinecone-client = [{ version = "^3.0.0" }, + { version = "^3.0.0", extras = ["grpc"], optional = true }] python-dotenv = "^1.0.0" openai = "^1.2.3" tiktoken = "^0.3.3" @@ -42,6 +43,7 @@ cohere = { version = ">=4.37", optional = true } cohere = ["cohere"] torch = ["pinecone-text"] transformers = ["transformers"] +grpc = ["pinecone-client"] [tool.poetry.group.dev.dependencies] @@ -76,6 +78,7 @@ module = [ 'pinecone', 'transformers.*', 'cohere.*', + 'pinecone.grpc' ] ignore_missing_imports = true diff --git a/src/canopy/knowledge_base/knowledge_base.py b/src/canopy/knowledge_base/knowledge_base.py index 1ead3573..23e400b0 100644 --- a/src/canopy/knowledge_base/knowledge_base.py +++ b/src/canopy/knowledge_base/knowledge_base.py @@ -4,15 +4,15 @@ from functools import lru_cache from typing import List, Optional, Dict, Any, Union -from pinecone import (ServerlessSpec, PodSpec, - Pinecone, PineconeApiException) +from pinecone import (ServerlessSpec, PodSpec, Index, + PineconeApiException) from canopy.utils.debugging import CANOPY_DEBUG_INFO try: - from pinecone import GRPCIndex as Index + from pinecone.grpc import PineconeGRPC as Pinecone except ImportError: - from pinecone import Index + from pinecone import Pinecone from canopy.knowledge_base.base import BaseKnowledgeBase from canopy.knowledge_base.chunker import Chunker, MarkdownChunker