From d6a2058984c19d42359d99f43bed279088d3cd49 Mon Sep 17 00:00:00 2001
From: James Briggs <35938317+jamescalam@users.noreply.github.com>
Date: Fri, 3 Jan 2025 19:48:45 +0400
Subject: [PATCH] fix: deprecated multiple routes query

---
 docs/00-introduction.ipynb        |  56 ----------------
 semantic_router/index/pinecone.py |   6 +-
 tests/unit/test_router.py         | 103 ------------------------------
 3 files changed, 4 insertions(+), 161 deletions(-)

diff --git a/docs/00-introduction.ipynb b/docs/00-introduction.ipynb
index e96e75b8..d464a2d4 100644
--- a/docs/00-introduction.ipynb
+++ b/docs/00-introduction.ipynb
@@ -279,62 +279,6 @@
         "sr(\"I'm interested in learning about llama 2\")"
       ]
     },
-    {
-      "cell_type": "markdown",
-      "metadata": {
-        "id": "dDZF2eN4f3p4"
-      },
-      "source": [
-        "We can also retrieve multiple routes with its associated score:"
-      ]
-    },
-    {
-      "cell_type": "code",
-      "execution_count": null,
-      "metadata": {
-        "id": "n27I7kmpf3p4",
-        "outputId": "2138e077-190b-41b7-a3eb-4fd76e2f59c2"
-      },
-      "outputs": [
-        {
-          "data": {
-            "text/plain": [
-              "[RouteChoice(name='politics', function_call=None, similarity_score=0.8595844842560181),\n",
-              " RouteChoice(name='chitchat', function_call=None, similarity_score=0.8356704527362284)]"
-            ]
-          },
-          "execution_count": 9,
-          "metadata": {},
-          "output_type": "execute_result"
-        }
-      ],
-      "source": [
-        "sr.retrieve_multiple_routes(\"Hi! How are you doing in politics??\")"
-      ]
-    },
-    {
-      "cell_type": "code",
-      "execution_count": null,
-      "metadata": {
-        "id": "zi4XJ7Amf3p4",
-        "outputId": "cf05cd65-d4f4-454a-ef05-77f16f37cc8f"
-      },
-      "outputs": [
-        {
-          "data": {
-            "text/plain": [
-              "[]"
-            ]
-          },
-          "execution_count": 10,
-          "metadata": {},
-          "output_type": "execute_result"
-        }
-      ],
-      "source": [
-        "sr.retrieve_multiple_routes(\"I'm interested in learning about llama 2\")"
-      ]
-    },
     {
       "cell_type": "markdown",
       "metadata": {},
diff --git a/semantic_router/index/pinecone.py b/semantic_router/index/pinecone.py
index 3fa22677..9e8b950e 100644
--- a/semantic_router/index/pinecone.py
+++ b/semantic_router/index/pinecone.py
@@ -109,7 +109,7 @@ class PineconeIndex(BaseIndex):
     dimensions: Union[int, None] = None
     metric: str = "dotproduct"
     cloud: str = "aws"
-    region: str = "us-west-2"
+    region: str = "us-east-1"
     host: str = ""
     client: Any = Field(default=None, exclude=True)
     async_client: Any = Field(default=None, exclude=True)
@@ -125,7 +125,7 @@ class PineconeIndex(BaseIndex):
         dimensions: Optional[int] = None,
         metric: str = "dotproduct",
         cloud: str = "aws",
-        region: str = "us-west-2",
+        region: str = "us-east-1",
         host: str = "",
         namespace: Optional[str] = "",
         base_url: Optional[str] = "https://api.pinecone.io",
@@ -145,6 +145,8 @@ class PineconeIndex(BaseIndex):
         self.api_key = api_key or os.getenv("PINECONE_API_KEY")
         self.base_url = base_url
 
+        logger.warning("Default region changed from us-west-2 to us-east-1 in v0.1.0.dev6")
+
         if self.api_key is None:
             raise ValueError("Pinecone API key is required.")
 
diff --git a/tests/unit/test_router.py b/tests/unit/test_router.py
index bd215242..e4b1e6be 100644
--- a/tests/unit/test_router.py
+++ b/tests/unit/test_router.py
@@ -981,109 +981,6 @@ class TestSemanticRouter:
         results = route_layer._semantic_classify_multiple_routes(query_results)
         assert results == expected, "Should ignore and not return unrecognized routes"
 
-    def test_retrieve_with_text(self, routes, index_cls, encoder_cls, router_cls):
-        encoder = encoder_cls()
-        index = init_index(index_cls, index_name=encoder.__class__.__name__)
-        route_layer = router_cls(
-            encoder=encoder,
-            routes=routes,
-            index=index,
-            auto_sync="local",
-        )
-        text = "Hello"
-        results = route_layer.retrieve_multiple_routes(text=text)
-        assert len(results) >= 1, "Expected at least one result"
-        assert any(
-            result.name in ["Route 1", "Route 2"] for result in results
-        ), "Expected the result to be either 'Route 1' or 'Route 2'"
-
-    def test_retrieve_with_vector(self, routes, index_cls, encoder_cls, router_cls):
-        encoder = encoder_cls()
-        index = init_index(index_cls, index_name=encoder.__class__.__name__)
-        route_layer = router_cls(
-            encoder=encoder,
-            routes=routes,
-            index=index,
-            auto_sync="local",
-        )
-        vector = [0.1, 0.2, 0.3]
-        if index_cls is PineconeIndex:
-            time.sleep(PINECONE_SLEEP)  # allow for index to be populated
-        results = route_layer.retrieve_multiple_routes(vector=vector)
-        assert len(results) >= 1, "Expected at least one result"
-        assert any(
-            result.name in ["Route 1", "Route 2"] for result in results
-        ), "Expected the result to be either 'Route 1' or 'Route 2'"
-
-    def test_retrieve_without_text_or_vector(
-        self, routes, index_cls, encoder_cls, router_cls
-    ):
-        encoder = encoder_cls()
-        index = init_index(index_cls, index_name=encoder.__class__.__name__)
-        route_layer = router_cls(
-            encoder=encoder,
-            routes=routes,
-            index=index,
-            auto_sync="local",
-        )
-        with pytest.raises(ValueError, match="Either text or vector must be provided"):
-            route_layer.retrieve_multiple_routes()
-
-    def test_retrieve_no_matches(self, routes, index_cls, encoder_cls, router_cls):
-        encoder = encoder_cls()
-        index = init_index(index_cls, index_name=encoder.__class__.__name__)
-        route_layer = router_cls(
-            encoder=encoder,
-            routes=routes,
-            index=index,
-            auto_sync="local",
-        )
-        text = "Asparagus"
-        if index_cls is PineconeIndex:
-            time.sleep(PINECONE_SLEEP)
-        results = route_layer.retrieve_multiple_routes(text=text)
-        assert len(results) == 0, f"Expected no results, but got {len(results)}"
-
-    def test_retrieve_one_match(self, routes_3, index_cls, encoder_cls, router_cls):
-        encoder = encoder_cls()
-        index = init_index(index_cls, index_name=encoder.__class__.__name__)
-        route_layer = router_cls(
-            encoder=encoder,
-            routes=routes_3,
-            index=index,
-            auto_sync="local",
-        )
-        text = "Hello"
-        # set low threshold
-        route_layer.set_threshold(threshold=0.1, route_name="Route 1")
-        if index_cls is PineconeIndex:
-            time.sleep(PINECONE_SLEEP)
-        results = route_layer.retrieve_multiple_routes(text=text)
-        assert len(results) == 1, f"Expected one result, and got {len(results)}"
-        matched_routes = [result.name for result in results]
-        assert "Route 1" in matched_routes, "Expected 'Route 1' to be a match"
-
-    def test_retrieve_with_text_for_multiple_matches(
-        self, routes_2, index_cls, encoder_cls, router_cls
-    ):
-        encoder = encoder_cls()
-        index = init_index(index_cls, index_name=encoder.__class__.__name__)
-        route_layer = router_cls(
-            encoder=encoder,
-            routes=routes_2,
-            index=index,
-            auto_sync="local",
-        )
-        text = "Hello"
-        route_layer.set_threshold(threshold=0.01, route_name=None)
-        if index_cls is PineconeIndex:
-            time.sleep(PINECONE_SLEEP)
-        results = route_layer.retrieve_multiple_routes(text=text)
-        assert len(results) == 2, "Expected two results"
-        matched_routes = [result.name for result in results]
-        assert "Route 1" in matched_routes, "Expected 'Route 1' to be a match"
-        assert "Route 2" in matched_routes, "Expected 'Route 2' to be a match"
-
     def test_set_aggregation_method_with_unsupported_value(
         self, routes, index_cls, encoder_cls, router_cls
     ):
-- 
GitLab