Skip to content

Commit

Permalink
feat: add init_async_index param
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescalam committed Jul 15, 2024
1 parent 95725f9 commit 997e6ce
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "semantic-router"
version = "0.0.51"
version = "0.0.52"
description = "Super fast semantic router for AI decision making"
authors = [
"James Briggs <[email protected]>",
Expand Down
1 change: 1 addition & 0 deletions semantic_router/index/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class BaseIndex(BaseModel):
utterances: Optional[np.ndarray] = None
dimensions: Union[int, None] = None
type: str = "base"
init_async_index: bool = False
sync: Union[str, None] = None

def add(
Expand Down
6 changes: 5 additions & 1 deletion semantic_router/index/pinecone.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def __init__(
namespace: Optional[str] = "",
base_url: Optional[str] = "https://api.pinecone.io",
sync: str = "local",
init_async_index: bool = False,
):
super().__init__()
self.index_name = index_name
Expand All @@ -84,7 +85,10 @@ def __init__(
raise ValueError("Pinecone API key is required.")

self.client = self._initialize_client(api_key=self.api_key)
self.async_client = self._initialize_async_client(api_key=self.api_key)
if init_async_index:
self.async_client = self._initialize_async_client(api_key=self.api_key)

Check warning on line 89 in semantic_router/index/pinecone.py

View check run for this annotation

Codecov / codecov/patch

semantic_router/index/pinecone.py#L88-L89

Added lines #L88 - L89 were not covered by tests
else:
self.async_client = None

Check warning on line 91 in semantic_router/index/pinecone.py

View check run for this annotation

Codecov / codecov/patch

semantic_router/index/pinecone.py#L91

Added line #L91 was not covered by tests

def _initialize_client(self, api_key: Optional[str] = None):
try:
Expand Down

0 comments on commit 997e6ce

Please sign in to comment.