From a2ef8fe56d5b6614fba88f25db05c10f6b80ba31 Mon Sep 17 00:00:00 2001 From: jamescalam Date: Wed, 20 Nov 2024 15:01:59 +0100 Subject: [PATCH 1/3] fix: function schemas --- semantic_router/layer.py | 2 +- semantic_router/schema.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/semantic_router/layer.py b/semantic_router/layer.py index f34ec9d1..ec051633 100644 --- a/semantic_router/layer.py +++ b/semantic_router/layer.py @@ -488,7 +488,7 @@ def sync(self, sync_mode: str, force: bool = False) -> List[str]: remote_utterances=remote_utterances, ) # generate sync strategy - sync_strategy = diff.to_sync_strategy() + sync_strategy = diff.get_sync_strategy(sync_mode=sync_mode) # and execute self._execute_sync_strategy(sync_strategy) return diff.to_utterance_str() diff --git a/semantic_router/schema.py b/semantic_router/schema.py index ca5e55c4..ef2b2190 100644 --- a/semantic_router/schema.py +++ b/semantic_router/schema.py @@ -98,6 +98,8 @@ def from_tuple(cls, tuple_obj: Tuple): """ route, utterance = tuple_obj[0], tuple_obj[1] function_schemas = tuple_obj[2] if len(tuple_obj) > 2 else None + if isinstance(function_schemas, dict): + function_schemas = [function_schemas] metadata = tuple_obj[3] if len(tuple_obj) > 3 else {} return cls( route=route, From 702a3ed563bfca457a3cdd65e07c9cfbdc6a7d1b Mon Sep 17 00:00:00 2001 From: jamescalam Date: Wed, 20 Nov 2024 15:05:26 +0100 Subject: [PATCH 2/3] feat: add test and update version --- docs/indexes/pinecone-sync-routes.ipynb | 2 +- docs/source/conf.py | 2 +- pyproject.toml | 2 +- semantic_router/__init__.py | 2 +- tests/unit/test_sync.py | 15 +++++++++++++++ 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/docs/indexes/pinecone-sync-routes.ipynb b/docs/indexes/pinecone-sync-routes.ipynb index 67738ebc..14e78905 100644 --- a/docs/indexes/pinecone-sync-routes.ipynb +++ b/docs/indexes/pinecone-sync-routes.ipynb @@ -6,7 +6,7 @@ "metadata": {}, "outputs": [], "source": [ - "!pip install -qU \"semantic-router[pinecone]==0.1.0.dev0\"" + "!pip install -qU \"semantic-router[pinecone]==0.1.0.dev1\"" ] }, { diff --git a/docs/source/conf.py b/docs/source/conf.py index aa9ffa73..2dae787f 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -15,7 +15,7 @@ project = "Semantic Router" copyright = "2024, Aurelio AI" author = "Aurelio AI" -release = "0.1.0.dev0" +release = "0.1.0.dev1" # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/pyproject.toml b/pyproject.toml index 42d11227..68881c73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "semantic-router" -version = "0.1.0.dev0" +version = "0.1.0.dev1" description = "Super fast semantic router for AI decision making" authors = ["Aurelio AI "] readme = "README.md" diff --git a/semantic_router/__init__.py b/semantic_router/__init__.py index a45ea30a..a2ed0d07 100644 --- a/semantic_router/__init__.py +++ b/semantic_router/__init__.py @@ -4,4 +4,4 @@ __all__ = ["RouteLayer", "HybridRouteLayer", "Route", "LayerConfig"] -__version__ = "0.1.0.dev0" +__version__ = "0.1.0.dev1" diff --git a/tests/unit/test_sync.py b/tests/unit/test_sync.py index 296da0d2..c2ddee90 100644 --- a/tests/unit/test_sync.py +++ b/tests/unit/test_sync.py @@ -381,6 +381,21 @@ def test_auto_sync_merge_force_remote( Utterance(route="Route 3", utterance="Boo"), ], "The routes in the index should match the local routes" + @pytest.mark.skipif( + os.environ.get("PINECONE_API_KEY") is None, reason="Pinecone API key required" + ) + def test_sync(self, openai_encoder, index_cls): + route_layer = RouteLayer( + encoder=openai_encoder, + routes=[], + index=init_index(index_cls), + sync=None, + ) + route_layer.sync("remote") + time.sleep(PINECONE_SLEEP) # allow for index to be populated + # confirm local and remote are synced + assert route_layer.is_synced() + @pytest.mark.skipif( os.environ.get("PINECONE_API_KEY") is None, reason="Pinecone API key required" ) From a5103d6513daaef0e2c882615f3b40f3cabdf5f3 Mon Sep 17 00:00:00 2001 From: jamescalam Date: Wed, 20 Nov 2024 15:17:16 +0100 Subject: [PATCH 3/3] fix: param --- tests/unit/test_sync.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test_sync.py b/tests/unit/test_sync.py index c2ddee90..6235088f 100644 --- a/tests/unit/test_sync.py +++ b/tests/unit/test_sync.py @@ -389,7 +389,7 @@ def test_sync(self, openai_encoder, index_cls): encoder=openai_encoder, routes=[], index=init_index(index_cls), - sync=None, + auto_sync=None, ) route_layer.sync("remote") time.sleep(PINECONE_SLEEP) # allow for index to be populated