Skip to content

Commit

Permalink
Merge pull request #352 from aurelio-labs/james/index-async-option
Browse files Browse the repository at this point in the history
feat: add init_async_index param
  • Loading branch information
jamescalam committed Jul 15, 2024
2 parents 95725f9 + 997e6ce commit 72ba7eb
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)
else:
self.async_client = None

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

0 comments on commit 72ba7eb

Please sign in to comment.