diff --git a/semantic_router/layer.py b/semantic_router/layer.py index 6f1b6a463b1ce0c39bb192e46e734b24e3ed9117..895e90a9dd07faac45b53c7ce08f2b7d4543987a 100644 --- a/semantic_router/layer.py +++ b/semantic_router/layer.py @@ -541,53 +541,3 @@ def threshold_random_search( for i, route in enumerate(route_names) } return score_thresholds - - -if __name__ == "__main__": - from semantic_router import Route - from semantic_router.encoders import OpenAIEncoder - from semantic_router.layer import RouteLayer - - # Define routes with example phrases - politics = Route( - name="politics", - utterances=[ - "isn't politics the best thing ever", - "why don't you tell me about your political opinions", - "don't you just love the president", - "don't you just hate the president", - "they're going to destroy this country!", - "they will save the country!", - ], - ) - - chitchat = Route( - name="chitchat", - utterances=[ - "how's the weather today?", - "how are things going?", - "lovely weather today", - "the weather is horrendous", - "let's go to the chippy", - ], - ) - - routes = [politics, chitchat] - - # Initialize the encoder - encoder = OpenAIEncoder() - - # Initialize the RouteLayer with the encoder and routes - rl = RouteLayer(encoder=encoder, routes=routes) - - # Test the RouteLayer with example queries - print( - rl.retrieve_multiple_routes("how's the weather today?") - ) # Expected to match the chitchat route - print( - rl.retrieve_multiple_routes("don't you love politics?") - ) # Expected to match the politics route - print( - rl.retrieve_multiple_routes("I'm interested in learning about llama 2") - ) # Expected to return None since it doesn't match any route - print(rl.retrieve_multiple_routes("Hi! How are you doing in politics??"))