Skip to content

Commit

Permalink
Update layer.py
Browse files Browse the repository at this point in the history
After a discussion with James we decided to just alter the existing update function.
  • Loading branch information
Siraj-Aizlewood committed Sep 29, 2024
1 parent 1f930a5 commit 6cb48dd
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions semantic_router/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class RouteLayer:
index: BaseIndex

def __init__(
self,
self
encoder: Optional[BaseEncoder] = None,
llm: Optional[BaseLLM] = None,
routes: Optional[List[Route]] = None,
Expand Down Expand Up @@ -832,22 +832,6 @@ def _vec_evaluate(self, Xq: Union[List[float], Any], y: List[str]) -> float:

def _get_route_names(self) -> List[str]:
return [route.name for route in self.routes]

def update_route_thresholds(self, threshold_dict: Dict[str, float]):
"""
Update thresholds for specified routes.
:param threshold_dict: A dictionary mapping route names to new threshold values.
:type threshold_dict: Dict[str, float]
"""
for route_name, new_threshold in threshold_dict.items():
route = self.get(route_name)
if route:
old_threshold = route.score_threshold
route.score_threshold = new_threshold
logger.info(f"Updated threshold for route '{route_name}' from {old_threshold} to {new_threshold}")
else:
logger.warning(f"Route '{route_name}' not found. Skipping threshold update.")


def threshold_random_search(
Expand Down

0 comments on commit 6cb48dd

Please sign in to comment.