Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions semantic_router/index/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,13 @@ async def aquery(
route_names = [self.routes[i] for i in idx]
return scores, route_names

def aget_routes(self):
async def aget_routes(self):
"""Get all routes from the index.

:return: A list of routes.
:rtype: List[str]
"""
logger.error("Sync remove is not implemented for LocalIndex.")
logger.error("Async get routes is not implemented for LocalIndex.")

def _write_config(self, config: ConfigParameter):
"""Write the config to the index.
Expand Down
17 changes: 2 additions & 15 deletions semantic_router/routers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def __init__(
self.aggregation = aggregation
if self.aggregation not in ["sum", "mean", "max"]:
raise ValueError(
f"Unsupported aggregation method chosen: {aggregation}. Choose either 'SUM', 'MEAN', or 'MAX'."
f"Unsupported aggregation method chosen: {aggregation}. Choose either 'sum', 'mean', or 'max'."
)
self.aggregation_method = self._set_aggregation_method(self.aggregation)
# to keep PostgresIndex backwards compatible we will default auto_sync to "local",
Expand Down Expand Up @@ -1295,19 +1295,6 @@ def _refresh_routes(self):
Not yet implemented for BaseRouter.
"""
raise NotImplementedError("This method has not yet been implemented.")
route_mapping = {route.name: route for route in self.routes}
index_routes = self.index.get_utterances()
new_routes_names = []
new_routes = []
for route_name, utterance in index_routes:
if route_name in route_mapping:
if route_name not in new_routes_names:
existing_route = route_mapping[route_name]
new_routes.append(existing_route)

new_routes.append(Route(name=route_name, utterances=[utterance]))
route = route_mapping[route_name]
self.routes.append(route)

def _get_hash(self) -> ConfigParameter:
"""Get the hash of the current routes.
Expand Down Expand Up @@ -1530,7 +1517,7 @@ def _set_aggregation_method(self, aggregation: str = "sum"):
return lambda x: max(x)
else:
raise ValueError(
f"Unsupported aggregation method chosen: {aggregation}. Choose either 'SUM', 'MEAN', or 'MAX'."
f"Unsupported aggregation method chosen: {aggregation}. Choose either 'sum', 'mean', or 'max'."
)

def _score_routes(
Expand Down
Loading