From 66ecf45823352653e3d5e84eb474af18be1a1711 Mon Sep 17 00:00:00 2001
From: James Briggs <35938317+jamescalam@users.noreply.github.com>
Date: Fri, 10 Jan 2025 08:16:37 +0000
Subject: [PATCH] fix: include_metadata logic

---
 semantic_router/index/base.py         |  2 +-
 semantic_router/index/hybrid_local.py |  5 ++---
 semantic_router/index/local.py        |  6 ++----
 semantic_router/index/qdrant.py       | 10 +++-------
 4 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/semantic_router/index/base.py b/semantic_router/index/base.py
index c99dd53e..63db6752 100644
--- a/semantic_router/index/base.py
+++ b/semantic_router/index/base.py
@@ -86,7 +86,7 @@ class BaseIndex(BaseModel):
         if self.index is None:
             logger.warning("Index is None, could not retrieve utterances.")
             return []
-        _, metadata = self._get_all(include_metadata=True)
+        _, metadata = self._get_all(include_metadata=True)  # include_metadata required
         route_tuples = parse_route_info(metadata=metadata)
         if not include_metadata:
             # we remove the metadata from the tuples (ie only keep 0, 1 items)
diff --git a/semantic_router/index/hybrid_local.py b/semantic_router/index/hybrid_local.py
index f35be7cd..704df257 100644
--- a/semantic_router/index/hybrid_local.py
+++ b/semantic_router/index/hybrid_local.py
@@ -61,13 +61,12 @@ class HybridLocalIndex(LocalIndex):
         """Gets a list of route and utterance objects currently stored in the index.
 
         :param include_metadata: Whether to include function schemas and metadata in
-        the returned Utterance objects - HybridLocalIndex only supports False.
+        the returned Utterance objects - HybridLocalIndex doesn't include metadata so
+        this parameter is ignored.
         :type include_metadata: bool
         :return: A list of Utterance objects.
         :rtype: List[Utterance]
         """
-        if include_metadata:
-            raise ValueError("include_metadata is not supported for HybridLocalIndex.")
         if self.routes is None or self.utterances is None:
             return []
         return [Utterance.from_tuple(x) for x in zip(self.routes, self.utterances)]
diff --git a/semantic_router/index/local.py b/semantic_router/index/local.py
index a3bf3d9d..9cccfc4a 100644
--- a/semantic_router/index/local.py
+++ b/semantic_router/index/local.py
@@ -68,13 +68,11 @@ class LocalIndex(BaseIndex):
         """Gets a list of route and utterance objects currently stored in the index.
 
         :param include_metadata: Whether to include function schemas and metadata in
-        the returned Utterance objects - HybridLocalIndex only supports False.
-        :type include_metadata: bool
+        the returned Utterance objects - LocalIndex doesn't include metadata so this
+        parameter is ignored.
         :return: A list of Utterance objects.
         :rtype: List[Utterance]
         """
-        if include_metadata:
-            raise ValueError("include_metadata is not supported for HybridLocalIndex.")
         if self.routes is None or self.utterances is None:
             return []
         return [Utterance.from_tuple(x) for x in zip(self.routes, self.utterances)]
diff --git a/semantic_router/index/qdrant.py b/semantic_router/index/qdrant.py
index 10095d56..42ef48c0 100644
--- a/semantic_router/index/qdrant.py
+++ b/semantic_router/index/qdrant.py
@@ -192,17 +192,13 @@ class QdrantIndex(BaseIndex):
         """Gets a list of route and utterance objects currently stored in the index.
 
         :param include_metadata: Whether to include function schemas and metadata in
-        the returned Utterance objects - QdrantIndex only supports False.
+        the returned Utterance objects - QdrantIndex does not currently support this
+        parameter so it is ignored. If required for your use-case please reach out to
+        semantic-router maintainers on GitHub via an issue or PR.
         :type include_metadata: bool
         :return: A list of Utterance objects.
         :rtype: List[Utterance]
         """
-        if include_metadata:
-            raise NotImplementedError(
-                "include_metadata is not supported for QdrantIndex. If required please "
-                "reach out to maintainers on GitHub via an issue or PR."
-            )
-
         # Check if collection exists first
         if not self.client.collection_exists(self.index_name):
             return []
-- 
GitLab