Skip to content

Commit

Permalink
Linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Siraj-Aizlewood committed Sep 30, 2024
1 parent 8b86773 commit 0866dcc
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions semantic_router/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,12 @@ def add(self, route: Route):
def list_route_names(self) -> List[str]:
return [route.name for route in self.routes]

def update(self, name: str, threshold: Optional[float] = None, utterances: Optional[List[str]] = None):
def update(
self,
name: str,
threshold: Optional[float] = None,
utterances: Optional[List[str]] = None,
):
"""Updates the route specified in name. Allows the update of
threshold and/or utterances. If no values are provided via the
threshold or utterances parameters, those fields are not updated.
Expand All @@ -446,16 +451,22 @@ def update(self, name: str, threshold: Optional[float] = None, utterances: Optio
"""

if threshold is None and utterances is None:
raise ValueError("At least one of 'threshold' or 'utterances' must be provided.")
raise ValueError(

Check warning on line 454 in semantic_router/layer.py

View check run for this annotation

Codecov / codecov/patch

semantic_router/layer.py#L453-L454

Added lines #L453 - L454 were not covered by tests
"At least one of 'threshold' or 'utterances' must be provided."
)
if utterances:
raise NotImplementedError("The update method cannot be used for updating utterances yet.")

raise NotImplementedError(

Check warning on line 458 in semantic_router/layer.py

View check run for this annotation

Codecov / codecov/patch

semantic_router/layer.py#L457-L458

Added lines #L457 - L458 were not covered by tests
"The update method cannot be used for updating utterances yet."
)

route = self.get(name)
if route:
if threshold:
old_threshold = route.score_threshold
route.score_threshold = threshold
logger.info(f"Updated threshold for route '{route.name}' from {old_threshold} to {threshold}")
logger.info(

Check warning on line 467 in semantic_router/layer.py

View check run for this annotation

Codecov / codecov/patch

semantic_router/layer.py#L462-L467

Added lines #L462 - L467 were not covered by tests
f"Updated threshold for route '{route.name}' from {old_threshold} to {threshold}"
)
else:
raise ValueError(f"Route '{name}' not found. Nothing updated.")

Check warning on line 471 in semantic_router/layer.py

View check run for this annotation

Codecov / codecov/patch

semantic_router/layer.py#L471

Added line #L471 was not covered by tests

Expand Down

0 comments on commit 0866dcc

Please sign in to comment.