diff --git a/semantic_router/layer.py b/semantic_router/layer.py index 7002dd6909560135e92e23fbe5e318531fbc0ef9..b4cbad80a26e51e7ac98f24f781081466f1c14d3 100644 --- a/semantic_router/layer.py +++ b/semantic_router/layer.py @@ -329,16 +329,16 @@ class RouteLayer: if isinstance(self.index, PineconeIndex): logger.debug("Initializing PineconeIndex index") self.index.index = self.index._init_index(force_create=True) - logger.debug("Checking for diffs") - local_utterances = self.to_config().to_utterances() - remote_utterances = self.index.get_utterances() - diff = UtteranceDiff.from_utterances( - local_utterances=local_utterances, - remote_utterances=remote_utterances, - ) - sync_strategy = diff.get_sync_strategy(self.auto_sync) - logger.debug(f"Sync strategy: {sync_strategy}") - self._execute_sync_strategy(sync_strategy) + logger.debug("Checking for diffs") + local_utterances = self.to_config().to_utterances() + remote_utterances = self.index.get_utterances() + diff = UtteranceDiff.from_utterances( + local_utterances=local_utterances, + remote_utterances=remote_utterances, + ) + sync_strategy = diff.get_sync_strategy(self.auto_sync) + logger.debug(f"Sync strategy: {sync_strategy}") + self._execute_sync_strategy(sync_strategy) def check_for_matching_routes(self, top_class: str) -> Optional[Route]: matching_route = next( diff --git a/tests/unit/test_layer.py b/tests/unit/test_layer.py index 67102f7c213ea78e5258440603ea692f86e2e125..0ef0c1a1fdb78ed8df5ebcd36606c7e152ac61aa 100644 --- a/tests/unit/test_layer.py +++ b/tests/unit/test_layer.py @@ -16,7 +16,7 @@ from semantic_router.route import Route from platform import python_version -PINECONE_SLEEP = 12 +PINECONE_SLEEP = 3 def mock_encoder_call(utterances): @@ -236,7 +236,7 @@ class TestIndexEncoders: @pytest.mark.parametrize("index_cls", get_test_indexes()) class TestRouteLayer: def test_initialization_dynamic_route( - self, dynamic_routes, index_cls + self, dynamic_routes, openai_encoder, index_cls ): index = init_index(index_cls) route_layer = RouteLayer( @@ -305,7 +305,7 @@ class TestRouteLayer: index = init_index(index_cls) route_layer = RouteLayer( encoder=openai_encoder, routes=routes, index=index, - auto_sync="local" if index_cls is PineconeIndex else None, + auto_sync="local", ) if index_cls is PineconeIndex: time.sleep(PINECONE_SLEEP) # allow for index to be populated