semantic_router.layer.RouteLayer#
- class semantic_router.layer.RouteLayer(encoder=None, llm=None, routes=None, index=None, top_k=5, aggregation='sum')#
Bases:
object- __init__(encoder=None, llm=None, routes=None, index=None, top_k=5, aggregation='sum')#
Methods
__init__([encoder, llm, routes, index, ...])acall([text, vector, simulate_static, ...])- rtype:
add(route)async_group_scores_by_class(query_results)- rtype:
Dict[str,List[float]]
check_for_matching_routes(top_class)- rtype:
Optional[Route]
delete(route_name)Deletes a route given a specific route name.
evaluate(X, y[, batch_size])Evaluate the accuracy of the route selection.
fit(X, y[, batch_size, max_iter])from_config(config[, index])from_json(file_path)from_yaml(file_path)get(name)- rtype:
Optional[Route]
get_thresholds()- rtype:
Dict[str,float]
group_scores_by_class(query_results)- rtype:
Dict[str,List[float]]
list_route_names()- rtype:
List[str]
retrieve_multiple_routes([text, vector])- rtype:
List[RouteChoice]
to_config()- rtype:
to_json(file_path)to_yaml(file_path)update(route_name, utterances)Attributes
score_thresholdencoderindex- delete(route_name)#
Deletes a route given a specific route name.
- Parameters:
route_name (
str) – the name of the route to be deleted
- evaluate(X, y, batch_size=500)#
Evaluate the accuracy of the route selection.
- Return type:
float