From 30f9bf8c992bed3f7e6264bcd6737d2053971ea0 Mon Sep 17 00:00:00 2001 From: tolgadevAI <164843802+tolgadevAI@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:47:03 +0300 Subject: [PATCH] update the exception --- semantic_router/layer.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/semantic_router/layer.py b/semantic_router/layer.py index c16700bf..6e34af8e 100644 --- a/semantic_router/layer.py +++ b/semantic_router/layer.py @@ -479,20 +479,12 @@ class RouteLayer: self.routes.append(route) def _add_routes(self, routes: List[Route]): - # create embeddings for all routes - # route_names, all_utterances, function_schemas = self._extract_routes_details( - # routes - # ) - # embedded_utterances = self.encoder(all_utterances) - # create route array - # add everything to the index if routes: for route in routes: logger.info(f"Adding `{route.name}` route") embeddings = self.encoder(route.utterances) if route.score_threshold is None: route.score_threshold = self.score_threshold - try: self.index.add( embeddings=embeddings, @@ -505,8 +497,10 @@ class RouteLayer: ), ) except Exception as e: - logger.error(f"index error: {e}") - raise Exception(f"index error: {e}") from e + logger.error( + f"Failed to add route `{route.name}` to the index: {e}" + ) + raise Exception(f"Indexing error for route `{route.name}`") from e def _add_and_sync_routes(self, routes: List[Route]): # create embeddings for all routes and sync at startup with remote ones based on sync setting -- GitLab