From cec65c7be710372109117f83b1c15e76d8ec7100 Mon Sep 17 00:00:00 2001 From: James Briggs <35938317+jamescalam@users.noreply.github.com> Date: Fri, 14 Feb 2025 12:31:09 +0400 Subject: [PATCH] chore: lint --- docs/indexes/postgres/postgres.ipynb | 6 +++--- semantic_router/encoders/bedrock.py | 1 - semantic_router/index/pinecone.py | 1 - semantic_router/routers/hybrid.py | 9 ++++++--- semantic_router/routers/semantic.py | 9 ++++++--- tests/unit/test_router.py | 1 - tests/unit/test_sync.py | 1 - 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/docs/indexes/postgres/postgres.ipynb b/docs/indexes/postgres/postgres.ipynb index f0f868d5..86931ead 100644 --- a/docs/indexes/postgres/postgres.ipynb +++ b/docs/indexes/postgres/postgres.ipynb @@ -97,9 +97,9 @@ "import os\n", "\n", "# Set Postgres connection string\n", - "os.environ[\"POSTGRES_CONNECTION_STRING\"] = (\n", - " \"postgresql://admin:root@localhost:5432/semantic_router\"\n", - ")\n", + "os.environ[\n", + " \"POSTGRES_CONNECTION_STRING\"\n", + "] = \"postgresql://admin:root@localhost:5432/semantic_router\"\n", "# Initialize the Postgres index\n", "postgres_index = PostgresIndex()" ] diff --git a/semantic_router/encoders/bedrock.py b/semantic_router/encoders/bedrock.py index 57779b4e..cdab5b93 100644 --- a/semantic_router/encoders/bedrock.py +++ b/semantic_router/encoders/bedrock.py @@ -198,7 +198,6 @@ class BedrockEncoder(DenseEncoder): embeddings = [] if self.name and "amazon" in self.name: for doc in docs: - embedding_body = {} if isinstance(doc, dict): diff --git a/semantic_router/index/pinecone.py b/semantic_router/index/pinecone.py index 96ce6788..723d8b5f 100644 --- a/semantic_router/index/pinecone.py +++ b/semantic_router/index/pinecone.py @@ -674,7 +674,6 @@ class PineconeIndex(BaseIndex): if self.base_url and "api.pinecone.io" in self.base_url: self.index.delete(ids=route_vec_ids, namespace=self.namespace) else: - response = requests.post( f"{self.index_host}/vectors/delete", json=DeleteRequest( diff --git a/semantic_router/routers/hybrid.py b/semantic_router/routers/hybrid.py index f3e9107c..6bc202f5 100644 --- a/semantic_router/routers/hybrid.py +++ b/semantic_router/routers/hybrid.py @@ -101,9 +101,12 @@ class HybridRouter(BaseRouter): if isinstance(routes, Route): routes = [routes] # create embeddings for all routes - route_names, all_utterances, all_function_schemas, all_metadata = ( - self._extract_routes_details(routes, include_metadata=True) - ) + ( + route_names, + all_utterances, + all_function_schemas, + all_metadata, + ) = self._extract_routes_details(routes, include_metadata=True) # TODO: to merge, self._encode should probably output a special # TODO Embedding type that can be either dense or hybrid dense_emb, sparse_emb = self._encode(all_utterances) diff --git a/semantic_router/routers/semantic.py b/semantic_router/routers/semantic.py index 72b28388..45e2aedd 100644 --- a/semantic_router/routers/semantic.py +++ b/semantic_router/routers/semantic.py @@ -73,9 +73,12 @@ class SemanticRouter(BaseRouter): if isinstance(routes, Route): routes = [routes] # create embeddings for all routes - route_names, all_utterances, all_function_schemas, all_metadata = ( - self._extract_routes_details(routes, include_metadata=True) - ) + ( + route_names, + all_utterances, + all_function_schemas, + all_metadata, + ) = self._extract_routes_details(routes, include_metadata=True) dense_emb = self._encode(all_utterances) self.index.add( embeddings=dense_emb.tolist(), diff --git a/tests/unit/test_router.py b/tests/unit/test_router.py index 4270fb6e..5f90be3d 100644 --- a/tests/unit/test_router.py +++ b/tests/unit/test_router.py @@ -81,7 +81,6 @@ def init_index( issues during testing. """ if index_cls is PineconeIndex: - if index_name: if not dimensions and "OpenAIEncoder" in index_name: dimensions = 1536 diff --git a/tests/unit/test_sync.py b/tests/unit/test_sync.py index b700cd9e..be99f282 100644 --- a/tests/unit/test_sync.py +++ b/tests/unit/test_sync.py @@ -115,7 +115,6 @@ def init_index( issues during testing. """ if index_cls is PineconeIndex: - if index_name: if not dimensions and "OpenAIEncoder" in index_name: dimensions = 1536 -- GitLab