Skip to content
Snippets Groups Projects
Commit 66ecf458 authored by James Briggs's avatar James Briggs
Browse files

fix: include_metadata logic

parent c63c1ac2
No related branches found
No related tags found
No related merge requests found
...@@ -86,7 +86,7 @@ class BaseIndex(BaseModel): ...@@ -86,7 +86,7 @@ class BaseIndex(BaseModel):
if self.index is None: if self.index is None:
logger.warning("Index is None, could not retrieve utterances.") logger.warning("Index is None, could not retrieve utterances.")
return [] 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) route_tuples = parse_route_info(metadata=metadata)
if not include_metadata: if not include_metadata:
# we remove the metadata from the tuples (ie only keep 0, 1 items) # we remove the metadata from the tuples (ie only keep 0, 1 items)
......
...@@ -61,13 +61,12 @@ class HybridLocalIndex(LocalIndex): ...@@ -61,13 +61,12 @@ class HybridLocalIndex(LocalIndex):
"""Gets a list of route and utterance objects currently stored in the index. """Gets a list of route and utterance objects currently stored in the index.
:param include_metadata: Whether to include function schemas and metadata in :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 :type include_metadata: bool
:return: A list of Utterance objects. :return: A list of Utterance objects.
:rtype: List[Utterance] :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: if self.routes is None or self.utterances is None:
return [] return []
return [Utterance.from_tuple(x) for x in zip(self.routes, self.utterances)] return [Utterance.from_tuple(x) for x in zip(self.routes, self.utterances)]
......
...@@ -68,13 +68,11 @@ class LocalIndex(BaseIndex): ...@@ -68,13 +68,11 @@ class LocalIndex(BaseIndex):
"""Gets a list of route and utterance objects currently stored in the index. """Gets a list of route and utterance objects currently stored in the index.
:param include_metadata: Whether to include function schemas and metadata in :param include_metadata: Whether to include function schemas and metadata in
the returned Utterance objects - HybridLocalIndex only supports False. the returned Utterance objects - LocalIndex doesn't include metadata so this
:type include_metadata: bool parameter is ignored.
:return: A list of Utterance objects. :return: A list of Utterance objects.
:rtype: List[Utterance] :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: if self.routes is None or self.utterances is None:
return [] return []
return [Utterance.from_tuple(x) for x in zip(self.routes, self.utterances)] return [Utterance.from_tuple(x) for x in zip(self.routes, self.utterances)]
......
...@@ -192,17 +192,13 @@ class QdrantIndex(BaseIndex): ...@@ -192,17 +192,13 @@ class QdrantIndex(BaseIndex):
"""Gets a list of route and utterance objects currently stored in the index. """Gets a list of route and utterance objects currently stored in the index.
:param include_metadata: Whether to include function schemas and metadata in :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 :type include_metadata: bool
:return: A list of Utterance objects. :return: A list of Utterance objects.
:rtype: List[Utterance] :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 # Check if collection exists first
if not self.client.collection_exists(self.index_name): if not self.client.collection_exists(self.index_name):
return [] return []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment