Skip to content

Commit 059dba2

Browse files
authored
Merge pull request #667 from totto/fix/aggregation-error-message-case
fix: correct aggregation error message case and aget_routes signature
2 parents df9722a + 556a803 commit 059dba2

2 files changed

Lines changed: 4 additions & 17 deletions

File tree

semantic_router/index/local.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,13 @@ async def aquery(
241241
route_names = [self.routes[i] for i in idx]
242242
return scores, route_names
243243

244-
def aget_routes(self):
244+
async def aget_routes(self):
245245
"""Get all routes from the index.
246246
247247
:return: A list of routes.
248248
:rtype: List[str]
249249
"""
250-
logger.error("Sync remove is not implemented for LocalIndex.")
250+
logger.error("Async get routes is not implemented for LocalIndex.")
251251

252252
def _write_config(self, config: ConfigParameter):
253253
"""Write the config to the index.

semantic_router/routers/base.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def __init__(
421421
self.aggregation = aggregation
422422
if self.aggregation not in ["sum", "mean", "max"]:
423423
raise ValueError(
424-
f"Unsupported aggregation method chosen: {aggregation}. Choose either 'SUM', 'MEAN', or 'MAX'."
424+
f"Unsupported aggregation method chosen: {aggregation}. Choose either 'sum', 'mean', or 'max'."
425425
)
426426
self.aggregation_method = self._set_aggregation_method(self.aggregation)
427427
# to keep PostgresIndex backwards compatible we will default auto_sync to "local",
@@ -1295,19 +1295,6 @@ def _refresh_routes(self):
12951295
Not yet implemented for BaseRouter.
12961296
"""
12971297
raise NotImplementedError("This method has not yet been implemented.")
1298-
route_mapping = {route.name: route for route in self.routes}
1299-
index_routes = self.index.get_utterances()
1300-
new_routes_names = []
1301-
new_routes = []
1302-
for route_name, utterance in index_routes:
1303-
if route_name in route_mapping:
1304-
if route_name not in new_routes_names:
1305-
existing_route = route_mapping[route_name]
1306-
new_routes.append(existing_route)
1307-
1308-
new_routes.append(Route(name=route_name, utterances=[utterance]))
1309-
route = route_mapping[route_name]
1310-
self.routes.append(route)
13111298

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

15361523
def _score_routes(

0 commit comments

Comments
 (0)