Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
Fixed GRPC support (#271)
Browse files Browse the repository at this point in the history
* [kb] Fixed grpc support

After the recent changes in pinecone-client 3.0.0, using the GRPC flavor was broken

* [pyproj] Added [grpc] extra

This extra install pinecone-client with its [grpc] extra

* [pyproj] Ignore pinecone.grpc missing types

The pinecone-client library doesn't provide stubs at the moment
  • Loading branch information
igiloh-pinecone authored Feb 5, 2024
1 parent 2ca606f commit 3188b26
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -76,6 +78,7 @@ module = [
'pinecone',
'transformers.*',
'cohere.*',
'pinecone.grpc'
]
ignore_missing_imports = true

Expand Down
8 changes: 4 additions & 4 deletions src/canopy/knowledge_base/knowledge_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3188b26

Please sign in to comment.